急!java 如何连 mysql ,驱动又在哪儿找!

解决方案 »

  1.   

    在网上搜JDBC驱动,一大堆网站可以下
      

  2.   

    我会用 JAVA 连 mssql 和 oracle ;
     mysql 正在学,你会?教教我呗
      

  3.   

    和那两种格式都是一样的,只是驱动改一下
    package sqldriver;
    import java.sql.*;
    import java.io.*;
    public class testMysql {public static void main(String[] args) {
    String tableName=null;//表名
    BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
    try{
    Class.forName("com.mysql.jdbc.Driver");//加载驱动程序
    System.out.println("OK,DownLoad the driver");
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost/hjl","root","123456");/*hjl为在MYSQL下建
    立的数据库名字,123456是进入数据库的密码*/
    con.setCatalog("hjl");
    System.out.println("GOOG,Connect the DataBase");
    Statement statement = con.createStatement();//数据库操作
    System.out.print("请输入表名:");
    tableName=input.readLine();String sql="SELECT * FROM "+tableName;
    ResultSet rs = statement.executeQuery(sql);
    System.out.print("请输入列名:");
    String cName=input.readLine();
    // 获得数据结果集合
    if(!rs.next())
    System.out.println("表名或列名输入有误或到了末尾");
    else {
    System.out.println("查询结果为:");
    do
    {
    String result=rs.getString(cName);
    result=new String(result.getBytes("ISO-8859-1"),"GB2312");
    System.out.println(result);
    }while(rs.next());
    }
    rs.close();
    con.close();
    }catch(Exception ex){
    System.out.println(ex);
    System.exit(0);
    }}
    }
      

  4.   

    Class.forName("com.mysql.jdbc.Driver");//加载驱动程序Connection   con=DriverManager.getConnection("jdbc:mysql://localhost/hjl","root","123456");/*hjl为在MYSQL下建
    立的数据库名字,123456是进入数据库的密码*/
    Statement   statement   =   con.createStatement();//数据库操作String   sql="SELECT   *   FROM   "+tableName;
    ResultSet   rs   =   statement.executeQuery(sql);while(rs.next()){
    System.out.println(rs.getString(1));}
    rs.close();
    con.close();这样看懂了吧?
      

  5.   

    org.git.mm.mysql.Driver    这个呢?