首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

Java中数据库连接的有关问题,谢啦

2012-01-12 
Java中数据库连接的问题,谢啦public String display(String newId,String information){try{Class.forName

Java中数据库连接的问题,谢啦
public String display(String newId,String information){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String source = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=SRS_info.mdb";
Connection cn = DriverManager.getConnection( source );
Statement stm = cn.createStatement();
******String sql = "SELECT information FROM student_info where id = + '"+newId+"'";
ResultSet st = stm.executeQuery(sql);

其中**的那一行中,我所查的具体列(information)是用另外的函数来调用的比如,String x = display(Main_Log.mainId, major);。那个函数中的参数是数据库中的某一列。可是这样是不行的,说是参数不足,期待是 1。
这是为什么呢,改怎么改啊
谢啦

[解决办法]
Main_Log.mainId

major
是表student中的列吗?
你再描述下问题
display是db函数吧。你这么写直接到数据库上执行下看看。

热点排行