データからデータベースに追加しようとしていて、クラス 12 ドライバーをロードしました。
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
Statement st = null;
PrintWriter pwinsert = response.getWriter();
String firstname=request.getParameter("fname");
String Ddate=request.getParameter("ddate");
String Email=request.getParameter("email");
String ContactNo=request.getParameter("contactNo");
String Address=request.getParameter("address");
String complaint=request.getParameter("complaint");
String dept=request.getParameter("dept");
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("driver loaded");
}
catch(ClassNotFoundException ex) {
System.out.println("driver not loaded");
}
String URL = "jdbc:oracle:thin:@localhost:1521:xe";
String Username = "system";
String Password = "toushif";
try
{
con = DriverManager.getConnection(URL,Username,Password);
ps = con.prepareStatement("INSERT INTO TOU (MOBILE,DDATE,NAME,EMAIL,ADDRESS,COMPLAINT,DEPT) VALUES (?, ?, ?, ?, ?, ?, ? )");
ps.setString(1,ContactNo);
ps.setString(2,Ddate);
ps.setString(3,firstname);
ps.setString(4,Email);
ps.setString(5,Address);
ps.setString(6,complaint);
ps.setString(7,dept);
int i = ps.executeUpdate();
pwinsert.println(i);
if(i!=0) {
pwinsert.println("data has been stored");
}
else {
pwinsert.println("data could not be stored");
}
}
catch(Exception e)
{
e.printStackTrace();
}
// TODO Auto-generated method stub
}
}
このエラーが発生する java.sql.SQLException: jdbc:oracle:thin:@localhost:1521:xe に適したドライバーが見つかりません
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at tou.nadaf.database.doPost(database.java:74)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)