[Microsoft][ODBC Microsoft Access Driver] 标准表达式中数据类型不匹配。 5
一个最简单的jdbc连接数据库Access的例子为什么会报这个异常?importjava.sql.*;publicclassjdbcDemo{publicstaticvo...
一个最简单的jdbc 连接数据库Access的例子 为什么会报这个异常?
import java.sql.*;
public class jdbcDemo{
public static void main(String args[]){
Connection con;
Statement sql;
ResultSet rs;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){
System.out.print(e);
}
try{
con = DriverManager.getConnection("jdbc:odbc:jinData","","");
sql = con.createStatement();
rs =sql.executeQuery("SELECT * FROM goods WHERE price>3000");
while(rs.next()){
String number = rs.getString(1);
String name = rs.getString(2);
Date date = rs.getDate("madeTime");
double price = rs.getDouble("price");
System.out.printf("%-4s", number);
System.out.printf("%-6s", name);
System.out.printf("%-15s", date.toString());
System.out.printf("%6s\n", price);
}
con.close();
}
catch(SQLException e){
System.out.print(e);
}
}
} 展开
import java.sql.*;
public class jdbcDemo{
public static void main(String args[]){
Connection con;
Statement sql;
ResultSet rs;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){
System.out.print(e);
}
try{
con = DriverManager.getConnection("jdbc:odbc:jinData","","");
sql = con.createStatement();
rs =sql.executeQuery("SELECT * FROM goods WHERE price>3000");
while(rs.next()){
String number = rs.getString(1);
String name = rs.getString(2);
Date date = rs.getDate("madeTime");
double price = rs.getDouble("price");
System.out.printf("%-4s", number);
System.out.printf("%-6s", name);
System.out.printf("%-15s", date.toString());
System.out.printf("%6s\n", price);
}
con.close();
}
catch(SQLException e){
System.out.print(e);
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询