java 板


LINE

以解决 没有加入 mysql-connector-java-5.0.8-bin.jar 的CLASSPATH 加入後就可以连接到资料库了!^^ 加入path,classpath 如http://0rz.tw/tRUTl 此篇 出现新的错误讯息? 实在是不晓得为何 冒昧请教各位... 我的path是 classpath是 运行javac可以出现help讯息... 如下 C:\Documents and Settings\Administrator>echo %classpath% .;C:\Program Files\Java\jdk1.7.0_01\lib;C:\Program Files\Java\jdk1.7.0_01\lib\to ols.jar; C:\Documents and Settings\Administrator>echo %path% C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;d:\AppServ\Apache2 ;d:\AppServ\php5;d:\AppServ\MySQL\bin;C:\Program Files\Java\jdk1.7.0_01\bin; C:\Documents and Settings\Administrator>javac Usage: javac <options> <source files> where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings ...... 新错误讯息如下(以重开mysql.apache.tomcat) description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:548) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:456) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) root cause javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver .... 小弟是新手 冒昧请教(此环境简易的jsp网页没有连mysql的jsp可以成功显示) 我是 1.安装xampp version 1.7.7 2.安装http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-windows-i586.exe 3.启动xampp control panel即可按下apache,mysql,tomcat启动成功 然後小弟模仿此页 http://www.9lessons.info/2008/09/jsp-login-page-to-connect-mysql-atabase.html 的里面的结构网页 先建立mysql里面一个 叫test的database 里面在放一个 user table 建立起那示范网页的user_id,password,... 然後将test资料夹(内有login.html,login.jsp,reg.html,reg.jsp,welcome.jsp) 放入c:\xampp\tomcat\webapps\ROOT\ 形成 c:\xampp\tomcat\webapps\ROOT\test 然後再浏览器里输入 http://localhost:8080/test/login.html 当输入帐号 密码後按送出到login.jsp 却会出现 type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: An exception occurred processing JSP page /jspmysql/login.jsp at line 7 4: String userid=request.getParameter("user"); 5: session.putValue("userid",userid); 6: String pwd=request.getParameter("pwd"); 7: Class.forName("com.mysql.jdbc.Driver"); 8: java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","r1234"); 9: Statement st= con.createStatement(); 10: ResultSet rs=st.executeQuery("select * from user where user_id='"+userid+"'"); 一直告诉我 Class.forName("com.mysql.jdbc.Driver");是错误的 改成 Class.forName("org.gjt.mm.mysql.Driver").newInstance(); 也一样 (其实很像问现在到底是该用哪一个叙述? 这两个功能有差吗?) 是我步骤有错吗?(我这里的mysql帐号是设定root密码是r1234) 怎都连不到mysql资料库... 请教大家 感谢!(这样子不得其门而入...>__<困扰)... --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 163.17.52.209 ※ 编辑: gotdreamed 来自: 163.17.52.209 (12/19 12:01)
1F:→ awert:你classpath里有driver嘛? com.mysql.jdb.Driver是对的没错 12/19 12:01
※ 编辑: gotdreamed 来自: 163.17.52.209 (12/19 13:01)
2F:→ gotdreamed:我跟http://0rz.tw/tRUTl 设定path,classpath完後错误 12/19 13:15
※ 编辑: gotdreamed 来自: 163.17.52.209 (12/19 13:20) ※ 编辑: gotdreamed 来自: 163.17.52.209 (12/19 13:23)
3F:→ awert:我是指driver有没有在classpath,不是jdk 12/19 13:41
4F:→ gotdreamed:感谢!查了一下!真的是这问题!解决了我初学的问题^^ 12/19 21:58
※ 编辑: gotdreamed 来自: 180.176.176.142 (12/19 21:59)







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:BabyMother站内搜寻

TOP