标题:class.forName报错,请指教
只看楼主
buffon1005
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-3-21
 问题点数:0 回复次数:2 
class.forName报错,请指教
<%
        final String DBDRIVER = "com.mysql.jdbc.Driver" ;
        final String DBURL = "jdbc:mysql://localhost/training" ;
        final String DBUSER = "root" ;
        final String DBPASSWORD = "root" ;
        Connection conn = null ;
        System.out.println("DB link");
    %>
    <%
        try
        {
            Class.forName(DBDRIVER); ;
            conn = DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD) ;
            String sql = "SELECT id,uid,name,password FROM person" ;
            PreparedStatement pstmt = null ;
            pstmt =conn.prepareStatement(sql);
            ResultSet rs = pstmt.executeQuery() ;
            System.out.println("DB query");
    %>

用的室MyEclipse,MySql驱动已添加
程序一执行到Class.forName(DBDRIVER); 就跳出,怎么回事啊
搜索更多相关主题的帖子: forName class String final 
2008-04-23 12:35
菜鸟也疯狂
Rank: 1
等 级:新手上路
帖 子:134
专家分:0
注 册:2007-3-20
得分:0 
URL有问题,final String DBURL = "jdbc:mysql://localhost/training" ;
final String DBURL = "jdbc:mysql://localhost:3306/training" ;要写端口号

2008-04-23 19:42
高寒
Rank: 2
等 级:论坛游民
帖 子:134
专家分:20
注 册:2005-10-25
得分:0 
端口号呢????

2008-06-04 17:42



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-210623-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.178775 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved