代码-报错:ORA-12505 求解答

问题描述

报错:ORA-12505 求解答

报错: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:appMerlinproduct11.2.0dbhome_1networkadminlistener.ora

Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:appMerlinproduct11.2.0dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:appMerlinproduct11.2.0dbhome_1binoraclr11.dll")
)
)
(SID_DESC =
(GLOBAL_DBNAME = ORCL)
(ORACLE_HOME = D:appMerlinproduct11.2.0dbhome_1)
(SID_NAME = ORCL)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)

ADR_BASE_LISTENER = D:appMerlin

解决方案

oracle账户的问题或者配置的文件,拒绝连接。

解决方案二:

http://blog.csdn.net/shen_xiao_wei/article/details/5729463

解决方案三:

把"jdbc:oracle:thin:@127.0.0.1:1521:merlin","SCOTT","tiger"里127.0.0.1改成localhost或者自己的IP试下

解决方案四:

ORA-12505 是tns配置错误,你可以看一下

ct=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:merlin","SCOTT","tiger");

怀疑你的实例应该是orcl,试试这个

ct=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl","SCOTT","tiger");

时间: 2025-01-28 04:10:58

代码-报错:ORA-12505 求解答的相关文章

maven-hadoop编译报错,跪求解答

问题描述 hadoop编译报错,跪求解答 [WARNING] Error injecting: org.apache.maven.plugin.antrun.AntRunMojo java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDecl

BPEL发布成功,最简单的HelloWorld,可在Web Services Explorer中调用,但是调用地址那种方法控制台报错如下,求解答!!!谢谢

问题描述 14:00:25,625ERROR[ODEService]ExceptionoccuredwhileinvokingODEorg.apache.ode.axis2.OdeFault:UnexpectedelementinSOAPbody:message{http://www.hit.edu.cn}processelement{www.hit.edu.cn}HelloWorldProcessRequest.atorg.apache.ode.axis2.util.SoapMessageCo

JFinal项目用tomcat启动 报错 在线等 求解答

问题描述 严重:ExceptionstartingfilterpageCacheFilterjavax.servlet.ServletException:Couldnotinitialiseservletfilter.atnet.sf.ehcache.constructs.web.filter.Filter.init(Filter.java:192)atorg.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFi

java定时器 run方法怎么返回值 我要返回result 代码里一直报错 晚生跪求解决

问题描述 java定时器 run方法怎么返回值 我要返回result 代码里一直报错 晚生跪求解决 public VirementResultInfo queryTransaction( final String bank, final TransactionInfo transactionInfo) { // final VirementResultInfo result = null; TimerTask task = new TimerTask() { @Override public v

java-openmeetings无法进入登录页面 页面报错Internal error 求高手解答

问题描述 openmeetings无法进入登录页面 页面报错Internal error 求高手解答 用的是apache-openmeetings-3.0.7 连接的是oracle 安装完成后访问一切正常,但是关掉red5 再次启动后 页面无法进入 页面报错:Internal error 后台报错信息为: ERROR 12-30 14:22:42.142 DefaultExceptionMapper.java 255077 170 org.apache.wicke t.DefaultExcept

leetcode第一题java代码报错。求原因?

问题描述 leetcode第一题java代码报错.求原因? package com.hust.ali.test; import java.util.*; /** 给定一个整数数组,发现两个数字,使得它们添加到一个特定的目标数. 函数twoSum应返回两个数字,使得它们加起来的目标,其中索引1必须小于索引2的所有. @author Cat */ public class TwoNumSum { /* @param args */ public static void main(String[] a

入门-JAVA 简短代码报错,就是发现不了问题

问题描述 JAVA 简短代码报错,就是发现不了问题 class StaticDemo { public static void main(String[] args) { Person.show(); } } class Person { String name;//成员变量 static String country = "CN"; public static void show() { System.out.println(country+":"); } } /

spring-这段代码报错 cannot be cast to com.iflve.domain.Employee

问题描述 这段代码报错 cannot be cast to com.iflve.domain.Employee public Employee checkEmployee(Employee emp) { String sql = "select * from employee where name=? and pwd=?" ; List<Employee> list = sessionFactory.getCurrentSession().createSQLQuery(sq

java用openoffice报错!急求。

问题描述 java用openoffice报错!急求. 下面这是报错内容在线等解决.哪位大神帮忙看看.下午就要交任务了~ 解决方案 求解答啊...... 解决方案二: 难道没人知道?????? 解决方案三: 让java与OpenOffice调情-结晶 (转载)