java.sql.SQLException:一般错误
这是我的代码: 例如,将值插入数据库并显示数据库中的值java.sql.SQLException:一般错误,java,Java,这是我的代码: 例如,将值插入数据库并显示数据库中的值 import java.sql.*; class DbEx{ public static void main(String args[]) throws SQLException{ try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c=DriverMana
import java.sql.*;
class DbEx{
public static void main(String args[]) throws SQLException{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:jaga","","");
Statement s=c.createStatement();
s.execute("INSERT INTO stud VALUES(2,'Nirmal',23,'Btech','Male',720043)");
ResultSet rs=s.executeQuery("SELECT Id,Name FROM stud");
while(rs.next()){
System.out.println("ID"+rs.getInt(0)+"\nName"+rs.getString(1));
}
c.close();
}
catch(Exception e){
System.out.println(e);
}
}
}
catch
SQLException
notException
那么您看到的错误是什么呢?请输入错误消息以便我们可以帮助您,同时更改连接行中chatch SQLException的throws SQLException常规主机也为第二次查询创建新语句。