简体   繁体   中英

how do I use different version of java

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?

您需要从类和构建路径中删除sqljdbc.jar ,并且使用sqljdbc4.jar (适用于Java 6及更高版本)。

Right click on your project --> properties and then Java compiler and then select the java version you need 在此输入图像描述

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

I got it.
I needed to change the Run/Debug Settings > Edit > Execution environment 在此输入图像描述

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM