Class.forName("org.gjt.mm.mysql.Driver");
connString = "jdbc:mysql://localhost/portal/?user=jsp";
Connection Conn = DriverManager.getConnection(connString);
Statement SQLStatement = Conn.createStatement();
String Query = "SELECT email FROM uuser";
ResultSet SQLResult = SQLStatement.executeQuery(Query);
while(SQLResult.next())
{
String author = SQLResult.getString("name");
System.out.println(author);
}finally(close();........)
报sqlexception说column 'name' cant found但是用insert into uuser values('ggyy','[email protected]')却可以执行
connString = "jdbc:mysql://localhost/portal/?user=jsp";
Connection Conn = DriverManager.getConnection(connString);
Statement SQLStatement = Conn.createStatement();
String Query = "SELECT email FROM uuser";
ResultSet SQLResult = SQLStatement.executeQuery(Query);
while(SQLResult.next())
{
String author = SQLResult.getString("name");
System.out.println(author);
}finally(close();........)
报sqlexception说column 'name' cant found但是用insert into uuser values('ggyy','[email protected]')却可以执行
错误在String author = SQLResult.getString("name");
为什么呢?
or
select name,email from uuser
ResultSet SQLResult = SQLStatement.executeQuery(Query);
while(SQLResult.next())
{
String author = SQLResult.getString("name");
System.out.println(author);
}
String author = SQLResult.getString(1);
to newman0708:
用数字我也试了,什么都没有输出,好象没有这一列一样
ResultSet SQLResult = SQLStatement.executeQuery(Query);
while(SQLResult.next())
{
String author = SQLResult.getString("name");
System.out.println(author);
}如果把String author = SQLResult.getString("name");注释掉
结果是system输出了两次author,所以错误是出在String author = SQLResult.getString("name");