见鬼了怎么可能呢?请位帮助一下这是怎么回事情。

03-09-21 lina
我使用jdk1.3 和 mysql-connector-java-3.0.8-stable(在www.mysql.com)下的。java_home和classpath都设置好了。

运行如下代码:

import java.sql.*;

public class DBConnection{

public static Connection conn;

public static Statement stmt;

public DBConnection(){

}

public void connect(){

try{

Class.forName("com.mysql.jdbc.Driver").newInstance();

conn= DriverManager.getConnection ("jdbc:mysql://localhost:3306/mysql","root","");

stmt = conn.createStatement ();

}catch(Exception e){

System.out.println("error:"+e.getMessage());

}

}

public void test() {

String sSql = "select count(*) from user";

int ret=0;

this.connect();

try{

ResultSet rs = stmt.executeQuery(sSql);

if (rs.next()) {

ret = rs.getInt(1);

}

}catch(java.sql.SQLException e){

System.out.println(" error:"+ee.getMessage());

}

System.out.println("count:"+ret);

}

public static void main(String[] arg){

DBConnection db=new DBConnection();

db.test();

}

}

可出现如下错误提示:

"

error:Invalid value for getInt() - 'q'

count:0

"

user表中有5条数据

请问那位大侠知道是怎么回事情。thx

charlie
2003-09-22 09:22
驱动配置字符类型

lyojbuilder
2003-09-22 22:43
言不搭题

猜你喜欢