我正在尝试将我的 JAVA 代码连接到我在本地拥有的 SQL Server。这就是我想要做的:
public static void main(String[] args) throws ClassNotFoundException, SQLException, InvalidFormatException, IOException {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection("jdbc:sqlserver://localhost" + "databaseName=talisman" + "user=karim" + "password=123");
//rest of the code
}}
我得到了这个例外:
Dec 18, 2012 11:29:40 AM com.microsoft.sqlserver.jdbc.SQLServerConnection <init>
SEVERE: Java Runtime Environment (JRE) version 1.6 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.6 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 cct.karim.karim.main(karim.java:62)
并且我很困......我会很感激你的帮助,但请在你的答案中具体
更新:
我正在使用 eclipse,我下载了 jbdc4 。你能告诉我如何将它包含在eclipse中吗?