I am trying to establish connection to SQL Server from eclipse. I added to the project build path the jar sqlserverjdbc.jar . This is my code:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//Connection m_Connection = DriverManager.getConnection(
// "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=TMO", "****", "****");
String url = "jdbc:sqlserver://10.25.50.14;databaseName=TMO;integratedSecurity=true";
//Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection(url);
Statement m_Statement = conn.createStatement();
When I call getConnection(url) I get an error:
Nov 17, 2014 1:08:43 AM com.microsoft.sqlserver.jdbc.SQLServerConnection SEVERE: Java Runtime Environment (JRE) version 1.7 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0. Exception in thread "main" java.lang.UnsupportedOperationException: Java Runtime Environment (JRE) version 1.7 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0. at com.microsoft.sqlserver.jdbc.SQLServerConnection.(SQLServerConnection.java:238) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at com.ccih.analytics.clustering.tmo.DexRunner.getKeyPhrasesFromNewNlpDB_W_SAMPLE(DexRunner.java:394) at com.ccih.analytics.clustering.tmo.DexRunner.main(DexRunner.java:59) ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2 JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:838]
Am I using the wrong jar ? I checked my eclipse project in the 'Referenced Libraries' and I saw the entry of the related jar with all the .class files