OCI方式连接oracle数据库失败

vc555 2015-08-19 11:42:59
type Exception report

message javax.servlet.ServletException: java.sql.SQLException:

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: javax.servlet.ServletException: java.sql.SQLException:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:502)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:412)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)


root cause

javax.servlet.ServletException: java.sql.SQLException:
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:868)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:797)
org.apache.jsp.MyJsp_jsp._jspService(MyJsp_jsp.java:82)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)


root cause

java.sql.SQLException:
oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:682)
oracle.jdbc.driver.T2CConnection.logon(T2CConnection.java:401)
oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
oracle.jdbc.driver.T2CConnection.<init>(T2CConnection.java:148)
oracle.jdbc.driver.T2CDriverExtension.getConnection(T2CDriverExtension.java:53)
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
java.sql.DriverManager.getConnection(DriverManager.java:664)
java.sql.DriverManager.getConnection(DriverManager.java:247)
org.apache.jsp.MyJsp_jsp._jspService(MyJsp_jsp.java:66)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)


OS:win7
数据库:oracle 11g.
jdk:1.8
classpath:%ORACLE_HOME%\jdbc\lib\ojdbc6.jar;%ORACLE_HOME%\jlib\orai18n.jar

请教各位,是什么原因,运行时报上面的错误呢?
下面是程序代码:
<%@page import="javax.servlet.*"%>
<%@page import="javax.servlet.http.*"%>
<%@page import="java.sql.*"%>

<%

Connection conn = null;
Class.forName("oracle.jdbc.driver.OracleDriver");

conn = DriverManager.getConnection("jdbc:oracle:oci:@mydb","dbuser","112233");

Statement stat = conn.createStatement();

String sql = "insert into test values('aabbcc')";

int rs = stat.executeUpdate(sql);

conn.close();

%>

...全文
100 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
vc555 2015-08-19
原来连接串应该这样写:sConnStr = "jdbc:oracle:oci8:sr/sr@ora199" 网上找的其他文章都没这样写。
回复
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2015-08-19 11:42
社区公告
暂无公告