i am trying to connect oracle database to netbeans. I followed instruction that given in https://netbeans.org/kb/docs/ide/oracle-db.html . I fulfilled all the steps that given site. but when i try to connect database by using servlet page i got an error.
error is given below,
Error Occured : Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor The Connection descriptor used by the client was: localhost:1521:XE [kavindu on KAVINDU]
I have no idea, what i next do,
My servlet code is given below,
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String customer_id = request.getParameter("customer_id");
String f_name = request.getParameter("f_name");
String l_name = request.getParameter("l_name");
String mobile_no = request.getParameter("mobile_no");
String address = request.getParameter("address");
try {
//loading driver
Class.forName("oracle.jdbc.driver.OracleDriver");
//creating connection with the database
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE [kavindu on KAVINDU]","kavindu","123456");
PreparedStatement ps = con.prepareStatement("insert into COMPACT_DISK values(?,?,?,?,?)");
ps.setString(1, customer_id);
ps.setString(2, f_name);
ps.setString(3, l_name);
ps.setString(4, mobile_no);
ps.setString(5, address);
int i = ps.executeUpdate();
if (i > 0) {
//out.println("Compact disk successfully inserted");
RequestDispatcher d = request.getRequestDispatcher("new.html");
d.forward(request, response);
}
} catch (ClassNotFoundException | SQLException | ServletException | IOException se) {
out.println("Error Occured : \n" + se.getLocalizedMessage());
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
[kavindu on KAVINDU]
part from the JDBC URL. Nowhere does the tutorial state you have to enter that. – a_horse_with_no_name