jsp中连接oracle的问题---菜鸟求助

palayang 2005-03-23 05:08:51
[求助]jsp中连接oracle的问题---菜鸟求助

我刚刚学jsp和oracle,在运行第一个程序时就遇到以下问题,请各位大侠指导:
代码如下:<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:test";
String user="system";
String password="test123";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from AA";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
出现的错误是:
description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:47: illegal character: \12288
[javac] ????String url="jdbc:oracle:thin:@localhost:1521:test123";
[[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:51: illegal character: \12288
[javac] ????Connection conn= DriverManager.getConnection(url,user,password);
[javac] ^
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:51: illegal character: \12288
[javac] ????Connection conn= DriverManager.getConnection(url,user,password);
[javac] ^
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:52: illegal character: \12288
[javac] ????Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
[javac] ^
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:52: illegal character: \12288
[javac] ????Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
[javac] ^
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:53: illegal character: \12288
[javac] ????String sql="select * from AA";
[javac] ^[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:54: illegal character: \12288
[javac] ????ResultSet rs=stmt.executeQuery(sql);
[javac] ^
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:55: illegal character: \12288
[javac] ????while(rs.next()) {
[javac] ^
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:55: illegal character: \12288
[javac] ????while(rs.next()) {
[javac] ^
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:66: illegal character: \12288
[javac] ????stmt.close();
[javac] ^
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:66: illegal character: \12288
[javac] ????stmt.close();
[javac] ^
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:67: illegal character: \12288
[javac] ????conn.close();
[javac] ^
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:67: illegal character: \12288
[javac] ????conn.close();
[javac] ^
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:68: illegal character: \12288
[javac] ????
[javac] ^
[javac] D:\Tomcat 4.1\work\Standalone\localhost\_\tes1_jsp.java:68: illegal character: \12288
[javac] ????
[javac] ^
[javac] 24 errors



at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:534)

另外,我想问一下在
String url="jdbc:oracle:thin:@localhost:1521:orcl";
Connection conn= DriverManager.getConnection(url,user,password);
中orcl、user、password到底在oracle中是什么?
希望各位高手能帮帮我这个菜鸟!!谢谢!!!!

...全文
36 点赞 收藏 1
写回复
1 条回复
zishuchen 2005年03月24日
呵呵,你的代码是从哪里拷贝到文件里的吧,每句前面应该是有特殊字符,只是没有显示出来而已。

打开在window系统中的《记事本》,新建立一个文件,然后把上面的语句拷贝到这个文档中,然后在拷贝粘贴到你的JSP文件中。

url 是访问数据库的地址,其中oracle表示oracle;thin表示用的协议;localhost表示用的机器名称,即本机;1521是连接oracle的端口号;orcl是oracle数据库的sid名称。
user,password自然是登录数据库的用户名和密码了。 :)
回复 点赞
发动态
发帖子
Web 开发
创建于2007-09-28

5.2w+

社区成员

34.1w+

社区内容

Java Web 开发
社区公告
暂无公告