gpt4 book ai didi

java - 驱动程序管理器无法解析为类型

转载 作者:行者123 更新时间:2023-12-01 09:46:44 25 4
gpt4 key购买 nike

下面提到了我的 JSP 程序。我正在尝试在 tomact 服务器中运行这个程序,但没有得到我所期望的结果。

      <%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="java.lang.*"%>
<%@page import="java.sql.DriverManager" %>
<%@page import="java.util.*"%>
<%@page import="java.sql.Connection"%>
<%!int a=9;%>
<%!int i=0;%>

<%


try{
Connection con=null;
PreparedStatement ps=null;
ResultSet rs=null,re=null;
Statement st=null;

String fname,lname,pass,retypepass,gender,dob,age,email,phn;

fname=request.getParameter("name");
lname=request.getParameter("name1");

pass=request.getParameter("pwd");
retypepass=request.getParameter("pwd1");
gender=request.getParameter("gender");
dob=request.getParameter("day");
email=request.getParameter("mailid");

for(i=0;i<email.length();i++)
{
a+=i;
}
out.println("your registration id is:"+a);
String regid=String.valueOf(a);
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
con=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:xe","system","system");
st=con.createStatement();
ps=con.prepareStatement("insert into Register3 values(?,?,?,?,?,?,?,?)");
ps.setString(1,fname);
ps.setString(2,lname);
ps.setString(3,regid);
ps.setString(4,pass);
ps.setString(5,retypepass);
ps.setString(6,gender);
ps.setString(7,dob);
ps.setString(8,email);


ps.executeUpdate();
%>
<html>
<head>
<script type="text/javascript">
alert(" Thank you for Registration...!!");
</script>
</head>
<body>
<center>
<h1><a href="login.html">login</a></h1>
</center>
</body>
</html>
<%
ps.close();
con.close();

}
catch(Exception e)
{
out.println("Error message:"+e);
%>
<html>
<head>
<script type="text/javascript">
alert(" THIS USER ALREDY EXIT...!!");
</script>
</head>
<body>
<center>
<h1><a href="registration.html"></a></h1>
</center>
</body>
</html>

<%


}

%>

上面的代码显示以下错误

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

An error occurred at line: 34 in the jsp file: /register.jsp
oracle.jdbc.OracleDriver cannot be resolved to a type
31: }
32: out.println("your registration id is:"+a);
33: String regid=String.valueOf(a);
34: DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
35: con=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:xe","system","system");
36: st=con.createStatement();
37: ps=con.prepareStatement("insert into Register3

values(?,?,?,?,?,?,?,?)");



Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:490)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:379)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:662)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

如何解决这个错误,请帮助我。请推荐我。

最佳答案

您在运行时错过了类路径中的 Oracle 驱动程序..

download并将其添加到 tomcat/lib 目录

关于java - 驱动程序管理器无法解析为类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37943074/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com