这是我的连接类
package gov.in.uid;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import gov.in.uid.AuthResponseDetails;
import java.sql.Driver;
import java.*;
public class Con_Savelog {
String Block, Remark;
public void ins( String Block, String Remark){
this.Block=Block;
this.Remark=Remark;
{
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con =DriverManager.getConnection
("jdbc:sqlserver://localhost;databaseName=AU_UID [sa on Default
schema];user=sa;password=dbadmin;");
System.out.println("Database Name: " +con.getMetaData().getDatabaseProductName());
PreparedStatement prep = con.prepareStatement("insert into UID_Log values (?, ?");
prep.setString(2, Block);
prep.setString(3, Remark);
prep.executeUpdate();
System.out.println("Data Inserted");
ResultSet rs = prep.executeQuery("SELECT * from UID_Log");
String a="";
String b="";
while(rs.next())
{
a=rs.getString(2);
a=rs.getString(3);
System.out.println("Block: " + a+"\r\n" + " Remark: "+ b);
}
con.close();
}
catch (Exception e)
{
e.printStackTrace();
System.err.println("Problem Connecting! "+e);
}
}
}
}
运行我的项目后,我收到以下错误:
"Problem Connecting! java.lang.UnsupportedOperationException: Java Runtime Environment (JRE) version 1.8 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0."
答案 0 :(得分:0)
你要做的是从类和构建路径中删除sqljdbc.jar(从库部分中删除它),并且只使用sqljdbc4.jar(适用于Java 6及更高版本)。
答案 1 :(得分:0)
使用tomcat 8并删除该jar。你必须使用Java1.8版本