www.mysql.com上面有MYSQL的JDBC DRIVER

解决方案 »

  1.   

    http://dev.mysql.com/downloads/connector/j/3.0.html
      

  2.   

    1. Download JDBC Driver Connector /J 3.0 2. copy the c:\mysql\mysql-connector-java-3.0.8-stable-bin.jar file to c:/mysql3. set CLASSPATHset CLASSPATH=c:\mysql\mysql-connector-java-3.0.8-stable-bin.jar;%CLASSPATH%   (Windows)export CLASSPATH=\mysql\mysql-connector-java-3.0.8-stable-bin.jar:${CLASSPATH} (Unix bash)
      

  3.   

    Thanks,i'll try my best to try it.
      

  4.   

    To mathematician(数学家)
    I have done your referenced three steps,but it still failed,can you help me test it!thanks!
    My code is following:import java.io.*;
    import java.sql.*;
    import com.mysql.jdbc.Driver;public class testMysql
    {
    public testMysql()
    {
    }

    public static void main(String[] args)
    {
    String username = "root";
    String password = "root";
    String url = "localhost/dxjsoft"; Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;

    try
    {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    }
    catch(Exception ex)
    {
    System.out.println ("1. ====> Cann't find the dirver program. "+ex);
    } try
    {
    con = DriverManager.getConnection("jdbc:mysql//dxjsoft",username,password);
    System.out.println ("Very good!");
    stmt = con.createStatement();
    rs = stmt.executeQuery("select * from dxj");
    while(rs.next())
    {
    //System.out.println ("Name: "+rs.getString(1)+'\t'+"Sno: "+rs.getString(2)+'\t'+"Age: "+rs.getString(3));
    System.out.println (rs.getString(1));
    }
    }
    catch(Exception ee)
    {
    System.out.println ("2. ====>"+ee);
    }
    finally
    {
    if(con == null) return;
    try
    {
    //rs.close();
    //stmt.close();
    con.close();
    }
    catch(Exception et)
    {
    System.out.println ("3. ====>"+et);
    }
    }
    }
    }
      

  5.   

    The result is: 
    2. ====>java.sql.SQLException: No suitable driver
    Press any key to continue...I need your help,thanks!
      

  6.   

    Driver name:  not "Class.forName("com.mysql.jdbc.Driver")", you can select another driver(org.gjt.mm.mysql.Driver)
      

  7.   

    I have tried these two methods,the exception is the same:No suitable driver.
    The key problem is the 2. ====>java.sql.SQLException, so there is something wrong with the following:
     "con = DriverManager.getConnection("jdbc:mysql//dxjsoft",username,password);" Anyway,thanks very much!
      

  8.   

    import com.mysql.jdbc.Driver;是多余的,
      

  9.   

    关键是无法解决,哪位能否提供一个完整的sample呢?
    谢谢·
      

  10.   

    我主页上有,可能对你有帮助。
    http://mascotzhuang.go.nease.net/
      

  11.   

    import java.sql.*;
    public class Test
    {
    public static void main(String[] args){

    try{
    Class.forName("com.mysql.jdbc.Driver");
    System.out.println("Success loading MySql Driver");
        Connection  con=DriverManager.getConnection("jdbc:mysql://localhost/classjava","root","");
    Statement sql=con.createStatement();
    ResultSet rs=sql.executeQuery("select * from bill");
    while(rs.next())
    {
    String name=rs.getString(1);
    System.out.println(name);
    System.out.print("");
    }
     con.close();
     
     
    }
    catch(Exception e)
    {
    System.out.println("Error");
    e.printStackTrace();
    }
     
      
        }
    }
    呵呵,偶可以运行