如果是出现一堆错误提示的话,最有可能是CLASSPATH没有配置好。

解决方案 »

  1.   

    Connection con;
    Statement stmt;
    ResultSet rs;
    String url ="jdbc:mysql://localhost/test?user=root&password=&useUnicode=true&characterEncoding=GBK"; try{
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    //Class.forName("com.codestudio.sql.PoolMan").newInstance();
    }catch(ClassNotFoundException e){
    System.out.println(e.toString());
    }catch(InstantiationException e){
    System.out.println(e.toString());
    }catch(IllegalAccessException e){
    System.out.println(e.toString());
    }
    try{
    con=DriverManager.getConnection(url);
    if(con!=null){
    stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    rs=stmt.executeQuery("select created_time from book where author_name='asdf'");

    while (rs.next()) {
                                      ………………
    }
    stmt.close();
    con.close();
    }
    else System.out.println("无效的连接");
    }catch(SQLException e){System.out.println(e.toString());}
      

  2.   

    把你的mm.mysql-2.0.14-bin.jar放到CLASSPATH中,或者放到%JAVA_HOME%\jre\lib\ext下
      

  3.   

    放到CLASSPATH,已经顺利连接好了,谢谢
    不过,在进行查询的时候出错,如下
    <%@ page contentType="text/html;charset=gb2312" %> 
    <% 
    java.sql.Connection sqlConn=null; 
    java.sql.Statement stmt;
    java.sql.ResultSet rs;Class.forName("org.gjt.mm.mysql.Driver").newInstance(); 
    sqlConn= java.sql.DriverManager.getConnection("jdbc:mysql://localhost/bbs","root","");
    try{
      stmt=sqlConn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    rs=stmt.executeQuery("select * from t1");

    while (rs.next()) {
                               Sring time=rs.getString(a);
                               System.out.println(time);
    }
    stmt.close();
    sqlConn.close();
    }
    catch(SQLException e){System.out.println(e.toString());}%>