Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.sql.SQLException:一般错误_Java - Fatal编程技术网

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
not
Exception
那么您看到的错误是什么呢?请输入错误消息以便我们可以帮助您,同时更改连接行中chatch SQLException的throws SQLException常规主机也为第二次查询创建新语句。