I am using Tomcat server 8
I have added Ojdbc7.jar in Lib
and using Oracle 11g (11.2.0.2) version
My code is :
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class PrintForm extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
//Variables declaration
String emp_name = req.getParameter("name");
String s = "INSERT into Emp values(?,?)";
try{
//Making connection with Oracle
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
//Inserting data into table
PreparedStatement pst = con.prepareStatement(s);
pst.setInt(1,1);
pst.setString(2,emp_name);
pst.executeUpdate();
con.close();
}catch(Exception e){
out.println(e);
}
}
}
And this is throwing ,
java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@localhost:1521:xe
this exception.
So what driver, or what JDK version I should use ? current version is 1.7