Tag: java

How to pass Table-Valued parameters from java to sql server stored procedure?

I have a Student class with the following attributes: Name, Department, Address, Grade. Now I have an ArrayList that contains some Student objects like this, List<Student> stuList = new ArrayList<Student>(); stuList.add(new Student(“Tom”,”Comp”, “123 street”, “A”)); stuList.add(new Student(“Jery”,”Comp”, “456 street”, “A+”)); stuList.add(new Student(“Mac”,”Maths”, “Dum Street”, “B”)); I need to pass this arraylist to the sql server […]

identity from sql insert via jdbctemplate

Is it possible to get the @@identity from the SQL insert on a Spring jdbc template call? If so, how?

SQL Server JDBC Error on Java 8: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption

I am getting the following error when connecting to a SQL Server database using version the Microsoft JDBC Driver: com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: “SQL Server returned an incomplete response. The connection has been closed. ClientConnectionId:98d0b6f4-f3ca-4683-939e-7c0a0fca5931”. We recently upgraded our […]

Native Library sqljdbc_auth.dll already loaded in another classloader

I have 2 java web apps that need to connect to SQL Server Database using Windows Integrated Authentication. The first one that is loaded works fine but the second one throws the exception: Native Library sqljdbc_auth.dll already loaded in another classloader The error above occurs when I place the sqljdbc_auth.dll in one of the folders: […]

The TCP/IP connection to the host localhost, port 1433 has failed

I’m getting this 2 errors repeatedly when I’m trying to connect eclipse with sql server through jdbc. Could anyone help me with this or explain why am I getting this? 1. The TCP/IP connection to the host localhost, port 1433 has failed. 2. The driver could not establish a secure connection to SQL Server by […]

Getting Hibernate and SQL Server to play nice with VARCHAR and NVARCHAR

I’m currently in the process of enabling UTF-8 characters in some tables of a large database. These tables are already of MS-SQL type NVARCHAR. Additionally, I have several fields using VARCHAR as well. There is a well known issue with Hibernate’s interactions with the JDBC driver (see e.g., Mapping to varchar and nvarchar in hibernate) […]

Getting the Return Value from JDBC MSSQL

I’m connecting to SQL Server (2005) through Java using the Microsoft SQL Server JDBC Driver 2.0. How do I get the return value from a stored procedure? I’m doing something like: Connection connection = dataSource.getConnection() CallableStatement proc = connection.prepareCall(“{ call dbo.mySproc() }”); proc.execute(); Should I be using execute()? executeQuery()? executeUpdate()? None of these seem to […]

Date columns in SQL-Server (MSSQL-JDBC 3.0) running under Java 1.7.0 retrieved as 2 days in the past

I have strange effects when retrieving columns of type DATE from SQLServer2008 using the Microsoft JDBC-Driver version 3.0 when running under the official Oracle JDK 1.7.0. Host OS is Windows Server 2003. All Date columns are retrieved as two days in the past with respect to the value actually stored in the column. I cooked […]

how to configure hibernate config file for sql server

Here is the config file for MySQL: <hibernate-configuration> <session-factory> <property name=”hibernate.connection.driver_class”>org.gjt.mm.mysql.Driver</property> <property name=”hibernate.connection.url”>jdbc:mysql://localhost/test</property> <property name=”hibernate.connection.username”>root</property> <property name=”hibernate.connection.password”>zgy01</property> <property name=”hibernate.connection.pool_size”>100</property> <property name=”show_sql”>false</property> <property name=”dialect”>org.hibernate.dialect.MySQLDialect</property> <!– Mapping files –> <mapping resource=”model.hbm.xml”/> </session-factory> </hibernate-configuration> What to specify for SQL Server 2005? I did it like this: <hibernate-configuration> <session-factory> <property name=”hibernate.connection.driver_class”>org.gjt.mm.mysql.Driver</property> <property name=”hibernate.connection.url”>com.microsoft.sqlserver.jdbc.SQLServerDriver</property> <property name=”hibernate.connection.username”>sa</property> <property name=”hibernate.connection.password”>lal</property> <property name=”dialect”>org.hibernate.dialect.SQLServerDialect</property> […]

Driver.getConnection hangs using SQLServer driver and Java 1.6.0_29

I didn’t know where to write something about this and decided to do it here. After loooong time debugging my program I could find out that calling Driver.getConnection(string, string, string) hangs the calling thread. Why(?), I really don’t know, but I could find out that this happens with java 1.6.0_29 and not with java 1.6.0_26. […]

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