我的数据库的名字:mysql 
user:dbuser
password:1234

解决方案 »

  1.   

    呵呵给您测试类
    import java.sql.*;
    /* *
     * Created on 2006-8-26
     *
     * TODO To change the template for this generated file go to
     * Window - Preferences - Java - Code Style - Code Templates
     *//**
     * @author Administrator
     * 
     * TODO To change the template for this generated type comment go to Window -
     * Preferences - Java - Code Style - Code Templates
     */
    class testjdbc { /**
     * 
     */
    public static void main(String[] args) {
    System.out.println("HELLO");
    System.out.println("ok");
    try{
    System.out.println("ok");
    Class.forName("com.mysql.jdbc.Driver");
    System.out.println("OK");
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=root&password=1234");
    Statement st = con.createStatement();
    ResultSet rs=st.executeQuery("select * from test");
    //ResultSet rs=st.executeQuery("INSERT INTO `test` (`Id`,`test`) VALUES (null,2)");
    while(!rs.isLast()){
    rs.next();
    System.out.println("test:" +rs.getString("id"));// 请在test数据库中建立表test(字段为id和test)
    System.out.println("0000ok" );
    }
    rs.close();
    con.close( );
    }
    catch(Exception e){
    e.printStackTrace();

    }


    }
    }
      

  2.   

    jsp比较难调试的!
    用j2se编译呵呵
      

  3.   

    谢谢xblue3(http://my.6cncn.cn) 
    我现在的问题是
    我不用数据源来连接的时候是没有问题的
    直接的class.forname来连接是没有任何的问题的
    但是使用数据源就出错了
    我在 Context context=new InitialContext();
               DataSource ds=(DataSource)context.lookup("java:comp/env/jdbc/mysql");
    在后面加一个检查ds的语句
    结果显示能连接到ds的 
    大家知道是怎么回事吗??
    谢谢大家!
    虚心向大家请教
      

  4.   

    <parameter>
          <name>url</name>
          <value>jdbc:mysql://localhost:3306/mysql?autoReconnect=true</value>
        </parameter>
    -------------------------------------------------
    可能这个参数有问题