报错:java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
(有两个类,一个是登录类,一个是登录的处理类)
主要代码:(登录类)
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html; charset=utf-8");
PrintWriter out=response.getWriter();
out.print("
welcome
");
out.print("
" +
"ID:
" +
"Password:
" +
"
" +
"");
}
处理类的代码:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("utf-8");
response.getWriter().print("aaaa");
String id=request.getParameter("id");
String password=request.getParameter("password");
Connection ct=null;
ResultSet rs=null;
PreparedStatement ps=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
ct=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:merlin","SCOTT","tiger");
ps=ct.prepareStatement("selcet * from U where id=? and password=?");
ps.setObject(1, id);
ps.setObject(2, password);
rs=ps.executeQuery();
if(rs.next())
{
request.getRequestDispatcher("/MainFrame").forward(request, response);
}else{
request.getRequestDispatcher("/Login").forward(request, response);
}
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}
网上有改listener.ora的说法,我改了还是不行啊
listener.ora Network Configuration File: D:\app\Merlin\product\11.2.0\dbhome_1\network\admin\listener.ora
Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\app\Merlin\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\app\Merlin\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
)
(SID_DESC =
(GLOBAL_DBNAME = ORCL)
(ORACLE_HOME = D:\app\Merlin\product\11.2.0\dbhome_1)
(SID_NAME = ORCL)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
ADR_BASE_LISTENER = D:\app\Merlin