package 数据库;
import java.sql.*;
class Sql {
void Sql(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException ex) {
System.out.println(ex.toString());
// ex.printStackTrace();
}
try {
String url="jdbc:odbc:addr";
Connection conn=DriverManager.getConnection(url);
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("slesct *form Student");
}catch (SQLException ce){
System.out.println(ce);
}
}
}
import java.sql.*;
class Sql {
void Sql(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException ex) {
System.out.println(ex.toString());
// ex.printStackTrace();
}
try {
String url="jdbc:odbc:addr";
Connection conn=DriverManager.getConnection(url);
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("slesct *form Student");
}catch (SQLException ce){
System.out.println(ce);
}
}
}
createStatement();
提示错误!
"Sql.java": incompatible types; found : java.sql.Connection, required: 数据库.Connection at line 29, column 47
"Sql.java": cannot find symbol; symbol : method createStatement(), location: class 数据库.Connection at line 30, column 38
你看看你的查询语句:slesct *form Student
应该是:select * from Student 撒!!!真是晕倒!!!!
select * from Student