Domanda

I've installed both java 6 and 7 and using eclipse to write a simple jdbc application. I have both sqljdbc4.jar and sqljdbc.jar in the lib folder. I'm getting this message...

Dec 18, 2013 9:29:51 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.<init>(SQLServerConnection.java:304)

at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1011)

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at sqldriver.doConnection(sqldriver.java:27)

at sqldriver.main(sqldriver.java:12)

If I'm suppose to be using 1.6 how would I go about doing that?

È stato utile?

Soluzione 4

I got it.
I needed to change the Run/Debug Settings > Edit > Execution environment enter image description here

And there I go.
It's not a permanent fix but it will do for now.

Altri suggerimenti

You need to remove sqljdbc.jar from the class and build path and only use sqljdbc4.jar (which is for Java 6 and higher).

Right click on your project --> properties and then Java compiler and then select the java version you need enter image description here

Try this example. It's easier and you don't need to add the sqljdbc jars.

I had a similar issue when I tried to import data from SQL Server into my Solr index (solr v1.4.0 on a Windows Server 2012 R2 machine). To fix the issue I deleted sqljdbc.jar from the solr lib directory and added sqljdbc4.jar to the same directory.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top