Tag: java

Fetch Resultset of created&filled MSSQL temp table over Java

query5 String query5 =”USE DBTwo\n” + “DECLARE @temp_table table (column1 VARCHAR(60))\n” + “insert into @temp_table (column1)\n” + “select column1 from real_table (nolock)”; query3 String query3 = “USE DBTwo\n” + “select column1 from @temp_table”; Connections; ResultSet rs1; Statement stmt; Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”); String connectionUrl = “jdbc:sqlserver://192.168.131.10;” +”databaseName=DBOne;” +”user=” + “exuser” + “;” + “password=”+”userpass” + “;” + “allowMultiQueries=true” […]

what does null entities are not supported by org.hibernate.event.def.EventCache mean?

I am getting the error at the point I try to save an entity. I only get this error when I have booted up my server, not when I run my unit tests using dbunit. I am trying to save an association. My unit test should be the exact same condition as that which I […]

Problem obtaining entities with uniqueidentifier primary key

In order to investigate whether Hibernate’s behavior is different than NHibernate’s for a particular usage scenario, I began writing a Java SE & Hibernate port of the relevant parts of my NHibernate-based application, but encountered a problem with obtaining an entity where the corresponding SQL Server 2008 R2 Express table uses a uniqueidentifier for the […]

jdbc:jtds Connection to SQL server

This question already has an answer here: Help me create a jTDS connection string 5 answers

Kerberos sql server datasource in Wildfly 8.2

I have a problem setting up integrated authentication with Kerberos towards a MS Sql Server on Wildfly 8.2.0. Here’s what I’ve done so far: Managed to get it going on Wildfly 9.0.2, simply because Wildfly 9 contains the “new” login module class org.jboss.security.negotiation.KerberosLoginModule. A security domain configured like this: <login-module code=”org.jboss.security.negotiation.KerberosLoginModule” flag=”required” module=”org.jboss.security.negotiation”> <module-option name=”storeKey” […]

JDBC How to get all generated keys from single insert with many values query?

I’m inserting multiple rows using a PreparedStatement with a single query: String query = “insert into MyTable (a,b,c) values (?,?,?),(?,?,?),(?,?,?),(?,?,?)”; // insert 4 rows in a single query PreparedStatement stmt = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS); // .. here: loop to set all 4 x 3 values in my prepared statement And I want to get the IDs […]

Incorrect syntax near the keyword 'table' and could not extract ResultSet

I have created a project with SQL Server which the files: UserDAO.java* public class UserDAO { private static SessionFactory sessionFactory; static { sessionFactory = HibernateUtility.getSessionFactory(); } @SuppressWarnings(“unchecked”) public static List<User> findAll() { Session session = sessionFactory.openSession(); Criteria crit = session.createCriteria(User.class); List<User> userList = crit.list(); return userList; } } UserService.java public class UserService { public static […]

Is there a best practice for showing database changes on a JSP

We need to show database changes on a JSP page. The Information in the Database is changed by a legacy System, so I don’t have any change to get an event on Data change. So the problem is to keep the Database Information and the JSP Page in sync. Our first approach is to poll […]

SQL Server Nvarchar and Java prepared statement

I have a question regarding inserting strings to SQL Server 2008 R2. When I try to insert strings with some national letters, I receive “?” instead. I know that adding N at the beginning of a string literal will fix this problem, but I’m using JDBC prepared statements, like this: INSERT INTO MyTable(col1, col2) VALUES […]

PreparedStatement – how specify to use default value of column

I have a table created like this: CREATE TABLE [dbo].[LogInfo]( [date_current] [datetime] NULL, [classname] [varchar](500) NULL, [output] [varchar](500) NULL ) ON [PRIMARY] GO ALTER TABLE [dbo].[LogInfo] ADD DEFAULT (getdate()) FOR [date_current] GO so the ‘date_current’ column defaults to the current date and time. I have a prepared statement like this: PreparedStatement psInsert_ = conn.prepareStatement(“INSERT INTO […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.