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]')却可以执行

解决方案 »

  1.   

    select email from uuser这句没有错
    错误在String author = SQLResult.getString("name");
    为什么呢?
      

  2.   

    "SELECT email FROM uuser"; //没有name,当然错
      

  3.   

    select * from uuser
    or
    select name,email from uuser
      

  4.   

    楼主你的sql写地不对,改成select name from uuser就可以了String Query = "SELECT name FROM uuser";
    ResultSet SQLResult = SQLStatement.executeQuery(Query);
    while(SQLResult.next())
    {
        String author = SQLResult.getString("name");
        System.out.println(author);
    }
      

  5.   

    试试这个
    String author = SQLResult.getString(1);
      

  6.   

    我在这里写错了,程序里没有写错
    to newman0708:
       用数字我也试了,什么都没有输出,好象没有这一列一样
      

  7.   

    String Query = "SELECT name FROM uuser";
    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");
      

  8.   

    我用的是mysql admin1.4,驱动用的是mm的3.1.6alpha.bin
      

  9.   

    用数字的话只能是PreparedStatement