ubuntu14.04上tomcat运行jsp网页连接数据库问题 5C

1)大神可以详细说明一下连接和操作数据库的原理和流程吗?
2)网页上数据怎么传递给数据库的,要经过操作系统的网络协议栈吗?
3)apache2打开php网页和tomcat运行jsp网页连接数据库有什么不同呢?
4)有没有详解这些原理的书籍推荐?我是小白求教

3个回答

jsp底层通过jdbc驱动访问数据库,但是都封装好了,调用起来你只要关心2个,一个是建立连接(数据库的服务器名、用户名密码),一个是查询(sql语句,条件、参数])

具体参考:
https://blog.csdn.net/qq_39654446/article/details/77600104

服务器查询了数据,jsp将查询的数据填充到网页,并且返回,数据库本身不需要在网络上传输,传输的是已经生成的html网页

从程序员的角度看,几乎没有区别。除了java和php的语法的不同以外。

weixin_38941602
weixin_38941602 回复caozhy: 崇拜,什么时候才能向你一样优秀啊
一年多之前 回复
caozhy
贵阳老马马善福专门编写代码的老马就是我! https://www.cnblogs.com/fuck1/p/5300616.html
一年多之前 回复
weixin_38941602
weixin_38941602 回复caozhy: 真的吗?这么酷老哥,爱死你了,我怎么去判断一下是不是走了内存管道呢。
一年多之前 回复
caozhy
贵阳老马马善福专门编写代码的老马就是我! 回复weixin_38941602: 如果是本机同时运行tomcat和mysql,不一定通过网络,而可能走内存管道
一年多之前 回复
weixin_38941602
weixin_38941602 回复caozhy: tamcat进程没有通过网络驱动访问3306的端口吗?我这边既没有显示java进程,也没有显示tomcat进程,只能看见mysql数据库的回复。
一年多之前 回复
caozhy
贵阳老马马善福专门编写代码的老马就是我! 回复weixin_38941602: tomcat运行jsp程序的时候,是进程内调用的,因此只有tmocat的进程。
一年多之前 回复
weixin_38941602
weixin_38941602 嗯,我有个疑问就是当我在网络模块监视3306端口访问时,通过apache2或者Nginx操作数据库的访问会有进程(apache2或php5-fpm)显示,而tomcat打开jsp时却没有java进程,这是为什么呢?
一年多之前 回复

java和php是有共同的特点,php扩展性比较差

首先个人只对jsp页面熟悉 php方面不太了解 个人认为 对于jsp页面可以去试着看一下 有关编程框架方面的东西 ssh ssm框架 看看人家的框架封装 相信你会理解的更透一点

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
tomcat JSP连接数据库问题
tomcat JSP连接数据库问题 java.lang.ClassNotFoundException: org.apache.jsp.index_jsp package mypackage; import Java.sql.*; public class DataConnection { public static void main(String[
tomcat连接Access数据库问题。
各位高手好,麻烦帮我看下这个数据库连接问题:rnrn做了一个BBS但是数据库就是连接不上。错误代码如下rnrnHTTP Status 500 - rnrn--------------------------------------------------------------------------------rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: java.lang.NullPointerExceptionrn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rnrnrnroot cause rnrnjava.lang.NullPointerExceptionrn org.apache.jsp.pass_jsp._jspService(pass_jsp.java:79)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.rnrn各位大大帮我看下吧,过几天就得交作业了。
tomcat连接数据库问题
用jsp通过tomcat连接数据库rntomcat报错:rncan't load jdbc driver class.rn请各位大侠指教rn急!谢谢!!rn
tomcat连接mysql数据库问题
数据库正常 直接用mysql登陆没有问题 rntomcat也正常 可一连接数据库就出错 ,这个是我是测试的 jsp代码rnrn<%@ page language="java" import="java.util.*" pageEncoding="gb2312" contentType="text/html"%> rn<%@ page import="java.sql.*"%> rn rn rn rn<% rnConnection conn=null; rnStatement stmt=null; rnResultSet rs=null; rntry rn //Class.forName("com.mysql.mysql.Driver"); rn //&autoReconnect=truern Class.forName("com.mysql.jdbc.Driver");rn rn conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3036/webases?user=root&password=niuniu&useUnicode=true&characterEncoding=gb2312"); rn stmt=conn.createStatement(); rn rs=stmt.executeQuery("select * from T_userinfo"); rn int rownum=0; rn while (rs.next())rn rn rownum++; rn String username=rs.getString(1); rn String password=rs.getString(2); rn%> rn <%=rownum %> <%=username+password %> rn<% %> rnrn<% rncatch(Exception e) rnout.println("这里报错:"+e.toString()); rnfinally rntry rnif(rs!=null) rnrs.close(); rnif(stmt!=null) rnstmt.close(); rnif(conn!=null) rnconn.close(); rncatch(SQLException sqle) rnout.println(sqle.getMessage()); rn rn %> rnrn rn rnrnrnrnrn这个是出错信息 rnrnrnrnrnrnrn这里报错:com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.net.ConnectException MESSAGE: Connection refused: connect STACKTRACE: java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(Unknown Source) at java.net.Socket.(Unknown Source) at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:173) at com.mysql.jdbc.MysqlIO.(MysqlIO.java:267) at com.mysql.jdbc.Connection.createNewIO(Connection.java:2739) at com.mysql.jdbc.Connection.(Connection.java:1553) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.apache.jsp.testmysql2_jsp._jspService(testmysql2_jsp.java:58) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Unknown Source) ** END NESTED EXCEPTION ** Last packet sent to the server was 0 ms ago. rn
tomcat连接sql2000数据库问题
我不知道TOMCAT的数据库连接池的具体作用是什么,所以直接用bean来进行的数据库连接。rn我在JSP里面调用bean来访问数据库,由于查询的时间比较长,测试发现在两个客户端同时进行查询的时候,每个客户端都无法显示查询结果,并且通过TOMCAT里面的正常结束程序无法结束,只有强行结束。rn如果一个客户端在查询的时候(没有得到查询结果前),另一个客户端连系统都无法登陆、并且不相应JSP页面的任何超连接,但是却能提交表单来进行查询。rn不知道哪位DX遇到过?rn
Tomcat连接数据库问题!!!!急
(1)我想问一下在Tomcat连接某个数据库的时候,是不是要在其中配置Tomcat\conf\server.xml和WEB。XML啊rn(2)那么如果要配置的话,该如何配置呢,谢谢大家
tomcat连接数据库问题,急救
import java.sql.*;rnpublic class T rnpublic static void main(String[] args) throws Exception rnString sql = "select * from tb";rnClass.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");rnConnection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://home:1433","sa","sa");rnStatement stmt = conn.createStatement();rnResultSet rs = stmt.executeQuery(sql);rnwhile(rs.next()) rnStudent s = new Student();rns.name = rs.getString(1);rns.id = rs.getInt(2);rnSystem.out.println(s);rnrnrnrs.close();rnstmt.close();rnrnrnrnclass Student rnString name;rnint id;rnpublic String toString() rnreturn "Student--> name:[" + name + "], id:[" + id + "]";rnrnrnrnrn这段测试的代码编译没有错误,但用java T命令就有错误了,是什么原因rnException in thread "main" java.lang.ClassNotFoundException: com.microsoft.jdbc.rnsqlserver.SQLServerDriverrn at java.net.URLClassLoader$1.run(URLClassLoader.java:199)rn at java.security.AccessController.doPrivileged(Native Method)rn at java.net.URLClassLoader.findClass(URLClassLoader.java:187)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:289)rn at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:235)rn at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Class.java:141)rn at T.main(T.java:5)rnrn
tomcat连接Oracle数据库问题
用JDBC直接连接数据库 ok 没问题rn可是用tomcat连接 就抛出异常 我用的Eclipse6.0 tomcat6.0 Oracle9i tomcat连接数据库连接池都配置好了rn请高手指点 我错在哪里 我的AddMessageServlet.java:76的代码是connection.close()//关闭连接 rn可是好像connection就没创建才会报错的。。。rn严重: Servlet.service() for servlet AddMessageServlet threw exceptionrnjava.lang.NullPointerExceptionrn at guestbook.AddMessageServlet.doPost(AddMessageServlet.java:76)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)rn at java.lang.Thread.run(Unknown Source)rn
jsp 的servlet连接数据库问题
这个是JSP工程中 注册模块的servlet ,工程可运行rn[code=Java]package servlet.control;rnimport mybean.data.*;rnimport java.sql.*;rnimport java.io.*;rnimport javax.servlet.*;rnimport javax.servlet.http.*;rnrnrn/**rn *rn * @author Administratorrn */rnpublic class HandleRegister extends HttpServlet rn public void init(ServletConfig config) throws ServletExceptionrn rn super.init(config);rn tryClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");rn catch(Exception e)rn rnpublic String handleString(String s)rntrybyte bb[]=s.getBytes("iso-8859-1");rn s=new String(bb);rn rncatch(Exception e)rn return s;rnrn public void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOExceptionrn rn Connection con;rn PreparedStatement sql;rn Register reg=new Register();rn request.setAttribute("register",reg);rn String logname=request.getParameter("logname").trim(),//功能删除字符串首部和尾部的空格。rn password=request.getParameter("password").trim();rn boolean isLD=true;rn boolean boo=logname.length()>0&&password.length()>0&&isLD;rn String backNews="";rn try con=DriverManager.getConnection("jdbc:odbc:message","","");rn String insertCondition="INSERT INTO message VALUES (?,?)";rn sql=con.prepareStatement(insertCondition);rn if(boo)rn sql.setString(1,handleString(logname));rn sql.setString(2,handleString(password));rn int m=sql.executeUpdate();rn if(m!=0)rn backNews="注册成功!";rn reg.setBackNews(backNews);rn reg.setLogname(logname);rn reg.setPassword(password);rn rn rn elsern backNews="信息填写不完整,请重新填写。";rn reg.setBackNews(backNews);rn rn con.close();rn rn catch(SQLException exp)rn backNews="该会员名字已被使用,请您更换名字"+exp;rn reg.setBackNews(backNews);rn rn RequestDispatcher dispatcher=rn request.getRequestDispatcher("showRegister.jsp");rn dispatcher.forward(request,response);rn rnpublic void doGet(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOExceptionrn doPost (request,response);rnrnrn[/code]rnrnrn数据库message表中现在只有两个数据,一个是logname 一个是password.rnrn显示结果是rnHello World!rn--------------------------rn该会员名字已被使用,请您更换名字java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 查询值的数目与目标字段中的数目不同。 注册会员名称: rn---------------------------rnrnrnrn
jsp 连接数据库问题!!急
错误提示:rnrnHTTP Status 500 - rnrn--------------------------------------------------------------------------------rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: Unable to compile class for JSP: rnrnAn error occurred at line: 7 in the generated java filernOnly a type can be imported. conpackage.Databean resolves to a packagernrnStacktrace:rn org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)rn org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)rn org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)rn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.rnrnrn--------------------------------------------------------------------------------rnrnrnrn源代码:<%@ page language="java"contentType="text/html;charset=GB2312"%>rn<%@ page import="java.sql.*"%>rn<%@ page import="conpackage.Databean"%> rn<% rnString id,pwd;rnResultSet rs=null;rnid=request.getParameter("uid");rnpwd=request.getParameter("upwd");rnClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");rnString url="jdbc:odbc:Driver=Microsoft Access Driver (*.mdb);DBQ="+ request.getRealPath("/") + "denglu/member.mdb";rnConnection con=DriverManager.getConnection(url,"","");rnif(rs!=null)rs=null;rnString sql= "select * from zhanghaoguanli where 用户名='" + idrn + "' and 密码 = '" + pwd+ "'";rnStatement stmt = con.createStatement ( );rn rs=stmt.executeQuery(sql);rn if(rs.next())rn rs.close();rn rs=null; rn%> rn rn<%rnelse rn out.println("用户名或密码输入错误!");rn rs.close();rn rs=null; rn rn%>rnrnrn求给出错误原因,以及解决办法
JSP连接数据库问题
我写了个简单用户登录 但是不知道为什么 就是不进入数据库查询抛出数据库异常 比如我输入admin 密码 123456rn下面的代码执行完是这样的rn系统产生的认证码为: 3149rn您输入的认证码为: 3149rn验证码输入相同,认证成功!rnrn您输入的用户名为: adminrn密码为: 123456rn[b][u]SQL异常!true [/u][/b] (为什么会出现这个 而不是登录成功 或失败?)rn[code=HTML]<%@ page contentType="text/html; [code=HTML]<%@ page contentType="text/html; charset=gb2312" language="java" errorPage=""%>rn<%@ page import="java.sql.*" %>rnrnrn 认证码验证页面rn rn rn rn rnrnrn<%rn String rand = (String) session.getAttribute("rand");rn String input =(String) session.getAttribute("input");rn String user_name= (String) session.getAttribute("user_name");rn String pass_word= (String) session.getAttribute("pass_word");rn%>rn系统产生的认证码为:rn<%= rand %> rn您输入的认证码为:rn<%= input %> rn验证码输入相同,认证成功! rn rn您输入的用户名为:rn<%= session.getAttribute("user_name") %> rn密码为:rn<%= session.getAttribute("pass_word") %> rnrn<%rn Connection con;rn Statement sql;rn ResultSet rs;rn boolean s=true;rn tryrn Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");rn;rn rn catch(ClassNotFoundException e)rn rn tryrn con=DriverManager.getConnection("jdbc:odbc:biyeseji","",""); rn sql=con.createStatement();rn String condition="select * from UserInfo where UserName='"+user_name+"'and PassWord='"+pass_word+"'";rn rs=sql.executeQuery(condition);rnrn if (rs.next())rn rn out.print("登陆成功");rn rn elsern rn out.print("登陆失败,用户名或密码错");rn rn rn catch(SQLException e1)rn rn out.print("SQL异常!");rn rnrn%>rnrn[/code]
JSP连接数据库问题。
type Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: An exception occurred processing JSP page /check.jsp at line 20rnrn17: String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=student";rn18: String username="sa";rn19: String userpwd="sa";rn20: Connection conn=DriverManager.getConnection(url, username, userpwd);rn21: Statement stmt=conn.createStatement();rn22: String sql="select * from Table_1 where account= '"+name+"'";rn23: ResultSet rs=stmt.executeQuery(sql);rnrnrnStacktrace:rn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:567)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:456)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:722)rnrnrnroot cause rnrnjavax.servlet.ServletException: java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=studentrn org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)rn org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)rn org.apache.jsp.check_jsp._jspService(check_jsp.java:101)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:722)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:722)rnrnrnroot cause rnrnjava.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=studentrn java.sql.DriverManager.getConnection(Unknown Source)rn java.sql.DriverManager.getConnection(Unknown Source)rn org.apache.jsp.check_jsp._jspService(check_jsp.java:82)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:722)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:722)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/7.0.20 logs.rnrnrn代码如下。rnrnrn<%rnrnString name=request.getParameter("text1");rnString pwd =request.getParameter("pwd1");rnrnClass.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();rnString url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=student";rnString username="sa";rnString userpwd="sa";rnConnection conn=DriverManager.getConnection(url, username, userpwd);rnStatement stmt=conn.createStatement();rnString sql="select * from Table_1 where account= '"+name+"'";rnResultSet rs=stmt.executeQuery(sql);rnrs.first();rnout.print(rs.getObject("account"));rnrnrnrnrn%>rnrnrn刚刚自学,打击真不小……
JSP 连接SQL2000数据库问题
在JSP中我用JDBC-ODBC可以连接SQL2000,但是用JDBC 纯JAVA方式老是连接不是,错误为:rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperExceptionrn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:395)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrnrnroot cause rnrnjava.lang.NullPointerExceptionrn com.messboard.dbconn.DBConn.executeQuery(DBConn.java:81)rn org.apache.jsp.index_jsp._jspService(index_jsp.java:65)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.rnrn
jsp 连接数据库问题
代码如下: rn<%@ page contentType="text/html; charset=GB2312" language="java" import="java.sql.*,java.util.*" errorPage="" %> rn rn rn 仓库信息 rn rnrn<%!String url,sql; %> rn<%!Connection conn; //定义数据库连接对象 %> rn<%!ResultSet rs; //定义结果集对象 %> rn<%!Statement stmt; //定义SQL语句对象 %> rn<%!int i; %> rn rn 仓库信息 rn rn rn rn 仓库号 rn 城市 rn 面积 rn 更改 rn 删除 rn rn<% rnrntry rn rnrnClass.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); rnString url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=company"; rnrnConnection conn=DriverManager.getConnection(url,"jspname","123456");//建立数据库的连接 rnstmt=conn.createStatement(); rnsql="select * from storehouse"; rnrs=stmt.executeQuery(sql); rnrn while(rs.next()) rn rn%> rn rn <%=rs.getString(1)%> rn <%=rs.getString(2)%> rn <%=rs.getString(3)%> rn 修改 rn 删除 rn rn<% rn rnrnrs.close(); rnstmt.close(); rnconn.close(); rnrncatch(Exception e) rnrn rnout.println(e); rn rn%>数据库连接成功! rn rn 添加新纪录 rn rn rnrnrnrn没有打印出 表中的项目,我表中确实天数据了 rn rn
jsp连接mysql数据库问题。
首先感谢您能抽出宝贵时间来帮组我解决问题。rn我的情况是这样的:jsp连接mysql数据库,通过mysqlconnector/J来连接。rn1。jsp已经可以正常运行。(apache+tomcat+mod_jk.so)rn2。mysql版本:3.23.54a。并且已经能够正常运行。同时做了如下操作:rn=》清理一些不必要的东西:rn =》删除test库:rn =》有关用户及其权限保存在mysql数据库中,其中关键是db表和user表,将db表清空rn =》然后对user库进行清理,并进行刷新:rn >mysql delete from user where user='' or host='localhost';rn >mysql flush privileges;rn=》建立一个用于测试的新的数据库:rn=》mysql>create database my_test;rn=》在这个库中建立一个数据表:rn=》mysql>create table my_test_table(test_column char(20) not null);rn=》mysql>insert into my_test_table values ('Hello,I'm MySQL!');rn=》grant命令建立一个新的用户shimin,该用户只对my_test这个库有SELECT、UPDATE、INSERT以及DELETE的权限。该用户的密码也是shimin:rn=》mysql>grant SELECT,UPDATE,INSERT,DELETE on my_test.* to shimin identified by 'shimin';rnrn3。jdbc:mysqlconnector/J。装于/mysqlconnector2.0.14下.rn4。将上述路径加入到classpath中。rn5。在Tomcat的/webapps/examples/WEB-INF/classes下建立一个mysqltest目录,将该文件保存在这个目录中,DBconn.java用来封装与数据库链接的操作。DBconn.java的内容如下:rn package Mysqltest;rn import java.sql.*;rn public class DBconnrn String DBDriver="com.mysql.jdbc.Driver";rn String ConnStr="jdbc:mysql://school:3306/my_test";rn String MyUser="shimin";rn String MyPassword="shimin";rn Connection conn = null;rn ResultSet rs = null;rn public DBconn()rn tryrn Class.forName(DBDriver);rn rn catch(java.lang.ClassNotFoundException e)rn System.err.println("DBconn (): " + e.getMessage());rn rn rn public ResultSet executeQuery(String sql)rn rs = null;rn tryrn conn = DriverManager.getConnection(ConnStr,MyUser,MyPassword);rn Statement stmt = conn.createStatement();rn rs = stmt.executeQuery(sql);rn rn catch(SQLException ex)rn System.err.println("aq.executeQuery:"+ex.getMessage());rn rn return rs;rn rn rn6。利用JDK的Javac命令编译DBconn.java形成相应的class文件。rn =》cd /tomcat4112/webapps/examples/WEB-INF/classes/mysqltest/rn =》javac -g -verbose DBconn.javarn7。在Tomcat的/webapps/examples/jsp目录下建立Mysqltest.jsp文件。其内容如下:rn <%@ page contentType="text/html; charset=gb2312" %>rn <%@ page language="java" import="java.sql.*" %>rn rn <%rn ResultSet RS = DBconn1.executeQuery("SELECT * FROM my_test_table");rn while (RS.next()) rn out.print(" " + RS.getString("test_column")+"");rn rn RS.close();rn %> rn8。结果出现如下错误:rn
jsp连接mysql数据库问题
请问:Mysql的JDBC驱动程序怎么使用?我已经得到驱动(一个jar)。是考到lib目录下就可以了?rn以下代码中的那个url:jdbc:mysql://localhost:4040/test 各部分是什么意思?rn请指点,我的测试不成功rnrn%@ page contentType="text/html;charset=GBK" %>rn<%@ page language="java" import="java.sql.*"%>rn<%rnConnection conn = null;rnClass.forName("org.gjt.mm.mysql.Driver").newInstance(); rnconn = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:4040/test","root","");rnif(conn==null)rnSystem.out.println("get Conn Error");rnrnStatement stmt=conn.createStatement();rnResultSet RS_result=null;rn%>rnrnrn 学习rnrn<%rnRS_result=stmt.executeQuery("select * from student");rnString Name;rnwhile(RS_result.next())rnrnName=RS_result.getString("name");rn%>rn<%=Name%>rn<%rnrnRS_result.close();rnstmt.close();rnconn.close();rn%>rnrnrnrn
jsp连接数据库问题
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="exception.jsp" %>rn rn   rn  <%/***********************************************rn/*rn/*DbTest.javarn/*http://www.knowsky.comrn/******************************************* */rnrnpublic class DbTest rnrn Connection con;rn Statement sta;rn ResultSet rs;rnrn String driver;rn String url;rn String user;rn String pwd;rn public DbTest()rn rn  driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";;rn  url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName =guolv";rn  user = "sa";rn  pwd = "pass";rn  init();rn rn public void init()rn rn  tryrn   Class.forName(driver);rn   System.out.println("driver is ok");rn   con = DriverManager.getConnection(url,user,pwd);rn   System.out.println("conection is ok");rn   sta = con.createStatement();rn   rs = sta.executeQuery("select * from logonerr");rn   while(rs.next())rn   System.out.println(rs.getInt("id"));rn  catch(Exception e)rn  rn   e.printStackTrace();rn  rn rnrn public static void main(String args [])//自己替换[]rn rn  new DbTest();rn rn rn  %> rn   rn   rnrnrn以上是代码 rn下面是错误代码rn刚学习jsp 不怎么看的懂rntype Exception reportrnrnmessagernrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexceptionrnrnorg.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSPrn org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:156)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnroot causernrnorg.apache.jasper.JasperException: Unable to load class for JSPrn org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:600)rn org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnroot causernrnjava.lang.ClassNotFoundException: org.apache.jsp.conn_005fsql_jsprn java.net.URLClassLoader$1.run(Unknown Source)rn java.security.AccessController.doPrivileged(Native Method)rn java.net.URLClassLoader.findClass(Unknown Source)rn org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134)rn org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)rn org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:598)rn org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:144)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrn
JBuilder2006下jsp连接数据库问题
做一个jsp连接数据库程序rn连接SQLServer2000数据库rn程序如下:rnrnrn<%@ page contentType="text/html; charset=gb2312" %>rn<%@ page import="java.lang.*,java.io.*,java.sql.*,java.util.*" %>rnrnrn rn<b>JDBC连接SQL数据库测试</b>rnrnrnrn rnJDBC连接SQL数据库测试rn rn<%rntryrn Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); rn String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";rnString user="sa";rnString password="850106";rnConnection conn=DriverManager.getConnection(url,user,password);rnStatement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);rnString sql="select job_id,job_desc from jobs";rn ResultSet rs=stmt.executeQuery(sql);rnwhile(rs.next())%>rn 您的第一个字段内容为: <%=rs.getString(1)%> rn 您的第二个字段内容是: <%=rs.getString(2)%> rn <% %>rn out.print("数据库操作成功,恭喜你!"); rn <% rs.close();rn stmt.close();rn conn.close();rn%>rn rncatch(Exception e)rn rn rn rn %>rnrnrn编译运行时提示如下:rn"jdbcsql.jsp": 'try' without 'catch' or 'finally'rn明明有啊,为什么说缺少呢,rn高手帮忙解释下rnrn
jsp 连接informix数据库问题
jsp 连接informix数据库问题rnrn已经安装了Informix JDBC Driver 2.21.JC3rn当连接数据库时提示rn“javax.servlet.ServletException: Unable to load class com.informix.jdbc.IfxDriver”rnrn这有几种原因?rn求救!!!rn
jsp连接SQLServer2000数据库问题
jsp连接SQLServer2000数据库时 出现的问题是Microsoft][ODBC SQL Server Driver][SQL Server]对象名 'Role' 无效。 而且我已确定数据库连接已经成功,请问高手这是什么问题 应该怎么解决?
请教JSP连接数据库问题?
错误提示:rnjava.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的描述器索引rnrn上面可能是那个方面的问题,如何解决?
JSP连接数据库问题?
数据库的连接是没有问题的了,执行下面的操作时就显示非法的游标状态rn能告诉我哪里错了么?rn我的数据库用的是Access2003 jdk1.3 web服务器是resin2.1rn//.........(前面的代码都差不多的)rnsql="select * from UserInfor";rnrs = stmt.executeQuery(sql);rnString getName = new String();rnrs.next();rngetName=rs.getString("username");rnout.println("getName");rnrnrnrs.close();rnstmt.close();rnconn.close();rn%>
求助!jsp连接数据库问题
我的配置是myeclipse+tomcat+sqlsever2000个人版rn已经安装jdbc驱动,采用直接连接数据库方式,*.jar文件已经拷贝到tomcat的lib目录下rn我用测试代码测试:rn<%@ page import="java.sql.*" contentType="text/html;charset=gb2312" %>rn  rn  rn  <%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();rn String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";rn //pubs 为你的数据库的rn String user="sa";rn String password="";rn Connection conn= DriverManager.getConnection(url,user,password);rn Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);rn String sql="select job_id,job_desc from jobs";rn ResultSet rs=stmt.executeQuery(sql);rn while(rs.next())%>rn    您的第一个字段内容为:<%=rs.getString(1)%> rn    您的第二个字段内容为:<%=rs.getString(2)%> rn  <% %>rn  <%out.print("数据库操作成功,恭喜你");%>rn  <%rs.close();rn stmt.close();rn conn.close();rn %>rn  rn   rn产生的错误代码如下:rnHTTP Status 500 - rnrn--------------------------------------------------------------------------------rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: /MyJsp.jsp(1,1) Unterminated <%@ page tagrn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrnrnroot cause rnrnorg.apache.jasper.JasperException: /MyJsp.jsp(1,1) Unterminated <%@ page tagrn org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)rn org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)rn org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:130)rn org.apache.jasper.compiler.Parser.parseDirective(Parser.java:520)rn org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)rn org.apache.jasper.compiler.Parser.parse(Parser.java:126)rn org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)rn org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)rn org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)rn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logsrnrn希望得到高人指点
jsp中的连接数据库问题
做网络聊天室时,登陆之后跳到主界面时,老是提示“java.sql.SQLException: [Microsoft][ODBC 驱动程序 管理器] 未发现数据源名称并且未指定默认驱动程序 ”这个错误。我用的是ACCESS数据库,而且已经指定了数据原了。连接数据库的程序如下:rnString dbUrl = "jdbc:odbc:name";rntryClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");catch(ClassNotFoundException e)rn rn tryrn Connection c = DriverManager.getConnection(dbUrl,user,password);//link databasern Statement s = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);rn ResultSet r =s.executeQuery("SELECT * FROM chat where Nickname='"+name+"'"rn );rn上面的NAME不就是数据源吗?rn请各位高手指点指点?本人不胜感激!
jsp连接数据库问题????
rn刚装好TOMCAT6.0 连接MYSQL测试没问题,JDK6.0rn可把java.sql.删掉就才出现rn在连接就出现rnrnorg.apache.jasper.JasperException: Unable to compile class for JSP: rnrnAn error occurred at line: 33 in the jsp file: /d.jsprnThe type Statement is ambiguousrn30: out.print("数据库连接成功!");rn31: rn32: out.print(" ");rn33: Statement statement = conn.createStatement();rn34: rn35: String sql="SELECT * FROM "+ tableName;rn36: rnrnrnStacktrace:rn org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)rn org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)rn org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)rn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnrnrnString url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPwd;rnrnClass.forName("com.mysql.jdbc.Driver").newInstance();rnrnrnjava.sql.Connection conn=DriverManager.getConnection(url);rnout.print("数据库连接成功!");rnrnout.print(" ");rnjava.sql.Statement statement = conn.createStatement();rnrnString sql="SELECT * FROM "+ tableName;rnrnjava.sql.ResultSet rs = statement.executeQuery(sql); rn
jsp连接access数据库问题
我的代码如下:rnimport java.io.*;rnimport java.sql.*;rnpublic class MobileDatabasernpublic static void main(String[] args)rntryrnClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");rnString dbUrl="jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=test.mdb";rnConnection con=DriverManager.getConnection(dbUrl,"",""); rnStatement state=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,rnResultSet.CONCUR_UPDATABLE);rn//执行SQL语句rnString sql="select * from table";rnResultSet rs=state.executeQuery(sql);rnrn//打印测试rnif( rs != null )rnwhile( rs.next() )rnSystem.out.println(" " + rs.getString("name"));rnrnrs.close();rncon.close();rnrnrncatch(Exception e) rne.printStackTrace();rnrnrnrnrnrn数据库表 name 文本rn age 数字rn 。。。。。。。rnrn//编译好像没有问题,运行就出现下面的东东,那是为什么? 该怎么解决?rn//还有关于jsp连接access到底该怎么写,请高手用代码示例,(把数据库表也写个)rn//感谢感谢rn错误为:java.lang.NoClassDefFoundError: MobileDatabase/javarn Exception in thread "main"
jsp连接oracle数据库问题
oracle数据库安装在本地的一台服务器上,我的机子安装了oracle客户端,经过配置,我可以用TOAD访问数据库,查看数据库中的数据,但是我想在jsp的formAction中对数据库进行操作,我还需不需要在odbc数据源中新建一个oracle的数据源呢还是不需要建数据源直接在程序中访问数据库啊,rnClass.forName("oracle.jdbc.driver.OracleDriver");rnConnection conn=DriverManager.getConnection("jdbc:oracle:thin:@202.197.37.37:1521:oracle","sbgl","sbgl");rnStatement stmt=conn.createStatement();rnstmt.executeUpdate(instr.getSql().toString());rnstmt.close();rnconn.close()rn我的这段程序老是报错,"java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver"rn是不是没有oracle的驱动啊,jdbc:oracle:thin:@202.197.37.37中的:thin表示什么意思啊rn有那位高手能不能给一个问题全面的解释啊,要是有一段例程就更好了,先谢谢.
jsp连接access数据库问题!
我用jbuilder2005进行access数据库连接时,出现connection refused:connect错误,以前从来没遇到过这样的。大家遇到过这样 的情况没阿 ? 是怎么解决的 ? 谢谢rnrn
JSP连接 MySQL 数据库问题!
我在Windows 2003下用JBuilder 2005 写的 JSP 程序 rn数据库为 MySQL(4.17版) 数据库驱动为 mysql-connector-java-3.0.16-ga-bin.jarrn可以从数据库中读取数据内容,发布程序到服务器上就不能读取数据库中的内容rnrn服务器环境为: Debian Linux + MySQL (4.0.21)rn
jsp 连接access数据库问题
我连接access 数据库是通过odbc的系统dsn连接的数据远xsrn 连接代码:rn<%rn String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";rn //String strdbFile = "D:\\Tomcat 5.0\\webapps\\ROOT\\db.mdb";rn //String strConn = "jdbc:odbc:Driver=Microsoft Access Driver (*.mdb);db=" + strdbFile+";DriverID=22;READONLY=TRUE";rn try rn Class.forName(DBDriver);rn rn catch(ClassNotFoundException e)rn rn out.println("失败");rn rn tryrn Connection con = DriverManager.getConnection("jdbc:odbc:xs","","");rn rn rn catch(SQLException e)rn rn out.println("连接失败");rn rn Statement stmt=con.createStatement(); rn %>rn连接提示总是在提示con 好象是不可以用。An error occurred at line: 10 in the jsp file: /jdbc.jsprnGenerated servlet error:rnD:\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\jdbc_jsp.java:71: cannot resolve symbolrnsymbol : variable con rnlocation: class org.apache.jsp.jdbc_jsprn Statement stmt=con.createStatement(); rn ^rn1 errorrn但是我把Statement stmt=con.createStatement(); 这句删除上面的连接也没有问题啊。!!rn请问各位大侠我该怎么办!!!!?我研究了一个月了,哭!!!rn
JSP连接数据库问题!!
本人前两步根据网上资料,测试JDK,TOMCAT都好了,第三步却......rn  写一个简单的用来测试连接SQL Server 2000的JSP代码rnrn  <%@ page import="java.lang.*, java.io.*, java.sql.*, java.util.*" contentType="text/html;charset=gb2312" %>rn  rn  rn  <% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();rn   String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";rn   //pubs 为你的数据库的rn   String user="sa";rn   String password="";rn   Connection conn= DriverManager.getConnection(url,user,password);rn   Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);rn   String sql="select job_id,job_desc from jobs";rn   ResultSet rs=stmt.executeQuery(sql);rn   while(rs.next())  %>rn    您的第一个字段内容为:<%=rs.getString(1)%> rn    您的第二个字段内容为:<%=rs.getString(2)%> rn  <%  %>rn  <% out.print("数据库操作成功,恭喜你"); %>rn  <% rs.close();rn   stmt.close();rn   conn.close();rn  %>rn  rn   rnrn  将上面的JSP代码保存为sql_test.jsp,放在/Root目录下。rnrn  在地址中输入:http://localhost:8080/sql_test.jsp 测试时总是弹出rnrnHTTP Status 500 - rnrn--------------------------------------------------------------------------------rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to compile class for JSPrn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:354)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnrnroot cause rnrnorg.apache.jasper.JasperException: Unable to compile class for JSPrn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:574)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnrnroot cause rnrnjava.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.rn org.apache.jasper.xmlparser.UTF8Reader.invalidByte(UTF8Reader.java:621)rn org.apache.jasper.xmlparser.UTF8Reader.read(UTF8Reader.java:492)rn org.apache.jasper.xmlparser.XMLEncodingDetector.load(XMLEncodingDetector.java:1007)rn org.apache.jasper.xmlparser.XMLEncodingDetector.skipString(XMLEncodingDetector.java:958)rn org.apache.jasper.xmlparser.XMLEncodingDetector.scanXMLDecl(XMLEncodingDetector.java:1216)rn org.apache.jasper.xmlparser.XMLEncodingDetector.getEncoding(XMLEncodingDetector.java:122)rn org.apache.jasper.xmlparser.XMLEncodingDetector.getEncoding(XMLEncodingDetector.java:110)rn org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:308)rn org.apache.jasper.compiler.ParserController.doParse(ParserController.java:172)rn org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)rn org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:167)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)rn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/6.0.1 logs.rnrnrn--------------------------------------------------------------------------------rnrnApache Tomcat/6.0.1rnrn高手帮我解决一下,另外我安装了JDK,TOMCAT好象windows检测不到卡巴了,说我没装杀毒,郁闷!!rn
jsp 连接 mysql数据库问题
昨晚忙到现在,一直为这个问题烦恼, 试了很多种方法,后来发现,jar包只要导入到web底下的WEB_INF目录然后添加下环境就ok了
jsp连接数据库问题?
我运行:rn<%@ page import='java.sql.*' %>rn<%rnClass.forName("org.gjt.mm.mysql.Driver");rnConnection conn = DriverManager.getConnectionrn ("jdbc:mysql://tecfa2.unige.ch:3306/COFFEEBREAK");rnStatement stmt = conn.createStatement();rnResultSet rs = stmt.executeQuery("select * from abc");rnwhile(rs.next())rn rn out.println(rs.getString("def") + " ");rnrn%>rnrn出现错误:rnorg.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.rnC:\tomcat\work\localhost_8080%2Fswell\_0002ffc_0002ejspfc_jsp_8.java:64: Ambiguous class: java.beans.Statement and java.sql.Statementrn Statement stmt = conn.createStatement();rn请问是怎么回事,会是jdbc的问题吗?rn
JSP 连接数据库问题
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");rnConnection con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433; DatabaseName=SPJ数据库","sa","634905");rn 我用这段话连接的数据库 在前面我也导入了包rn <%@ page import="com.microsoft.sqlserver.jdbc.*" %>rnrn但是JSP一直报错 说我的connection 和Driver can not be resolved a type rn 纳闷很久了 求大神啊!
请问jsp连接数据库问题
我在menu.jsp里面,通过 parent.data.location.href = "data.jsp?id=" id;来连接data.jsp显示数据页面rn在data.jsp里通过rnrnrn<%rnString id=request.getParameter("id");rnrntryrn testdb.connect();rn String s = "select * from budget where budget_code like '" + id + "%' order by budget_code";rn testdb.query(s);rn%>rn rn<%rnwhile(testdb.next())rnrn%>rn rn <% rn for(int j = 1;j<7;j++)rn %> rn <%=testdb.getString(j)%>rn <%%> rn rn<%%>rnrn<%rn testdb.close();rnrncatch(Exception e)rnrn out.println(e);rnrn%>rn来显示数据.为什么没有结果显示呢
JSP连接数据库问题,急!!!
平台IIS+TOMCat.rn连接MsSQL数据库.rn已经设置了环境变量CLASSPATH,PATH,Java_HOME,TOMCAT_HOME,也装了ms jdbc驱动rn在执行<%@ page import="com.microsoft.jdbc.sqlserver.*"%> 或rn<%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance()%>时rn提示错误信息系 Not Found com.microsoft.jdbc.sqlserver.* 或rnNot Found com.microsoft.jdbc.sqlserver.SQLServerDriverrn
jsp 连接sqlserver2000数据库问题
我的连接数据库程序:rnpublic boolean connect()rn tryrn Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();rn String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=bookstor";rn String user="sa";rn String password="";rn con=DriverManager.getConnection(url,user,password);rn stmt=con.createStatement();rn catch(Exception ee)System.out.println("connect db error:"+ee.getMessage());rn return false;rn rn return true;rn rnrn程序在运行时老连接不上数据库,调试结果为:rnee: java.lang.Exception = java.sql.SQLException@1977"java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket."rnSQLState: java.lang.String = java.lang.String@1981"08001"rnvendorCode: int = 0rnnext: java.sql.SQLException = java.sql.SQLException@1982"java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Connection refused: connect"rndetailMessage: java.lang.String = java.lang.String@1983"[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket."rncause: java.lang.Throwable = java.sql.SQLException@1977"java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket."rnstackTrace: java.lang.StackTraceElement[] = nullrnrn请问这个是什么方面的错误(本人刚学jsp)
相关热词 c#检测非法字符 c#双屏截图 c#中怎么关闭线程 c# 显示服务器上的图片 api嵌入窗口 c# c# 控制网页 c# encrypt c#微信网页版登录 c# login 居中 c# 考试软件