mysql有自己本身的驱动程序,直接加载后就能访问数据库了,
不是一定需要jdbc 的!

解决方案 »

  1.   

    //@author:Andy
    //@version:1.0
    //function:query data from databse coffeebreak,TABLE COFFEES
    import java.sql.*;
    public class Query
    {
    public static void main(String [] args)
    {
    String url = "jdbc:mysql://localhost/coffeebreak";
    Connection con;
    Statement stmt;
    String qu = "select COF_NAME, PRICE from coffees where PRICE<9.0";
    try
    {
    Class.forName("com.mysql.jdbc.Driver");//看起来虽然不顺眼,但是可以支持中文
    }
    catch(ClassNotFoundException e)
    {
    System.err.println("Class Not Found!");
    System.err.println("e.getMessage()");

    }
    try
    {
    con = DriverManager.getConnection(url,"root","");
    stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(qu);
    System.out.println("Coffee Break Coffees and Prices:");
    while(rs.next())
    {
    String name = rs.getString("COF_NAME");
    float price = rs.getFloat("PRICE");
    System.out.println("Coffee Name: "+name+" Price: "+price);
    }

    }
    catch(SQLException e)
    {
    System.err.println("SQLException:"+e.getMessage());
    }
    }
    }
      

  2.   

    http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
      

  3.   

    Class.forName("org.gjt.mm.mysql.Driver").newInstance(); String url ="jdbc:mysql://localhost/softforum?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1" 前提是你有JDBC驱动....
      

  4.   

    驱动程序怎么安装.CLASSPATH怎么设置???