Java GWT-Oracle JDBC连接问题
我很难连接到Oracle数据库OJDBCJava GWT-Oracle JDBC连接问题,java,oracle,gwt,jdbc,Java,Oracle,Gwt,Jdbc,我很难连接到Oracle数据库OJDBC Error: 无法连接到数据库。异常消息:I/O错误:网络适配器无法建立连接 我正在使用GoogleWebToolkit,并在我的项目中添加了一个SQL数据库。 数据库名称为Agenda 我搜索了很多,似乎这个问题对很多人来说都很常见,但无法克服这个问题。 我已经下载了ojdbc6.jar并将其添加到我的构建路径中。 我已经刷新、关闭、打开和重新打开,但仍然看到错误 我的规格: Windows 7 x64 Springsource-在Eclip
Error:
无法连接到数据库。异常消息:I/O错误:网络适配器无法建立连接
我正在使用GoogleWebToolkit,并在我的项目中添加了一个SQL数据库。
数据库名称为Agenda
我搜索了很多,似乎这个问题对很多人来说都很常见,但无法克服这个问题。
我已经下载了ojdbc6.jar并将其添加到我的构建路径中。
我已经刷新、关闭、打开和重新打开,但仍然看到错误
我的规格:
Windows 7 x64
Springsource-在Eclipse中也尝试过
private static final long serialVersionUID = 1L;
private Connection connection = null;
private Properties props = null;
private ClassLoader cl = null;
private String databaseURL = "";
private String databaseUser = "";
private String databasePass = "";
public void init() {
try {
// Load the database connection properties from com.gwt.agenda.GWTAgendaSample.properties
props = new Properties();
cl = this.getClass().getClassLoader();
InputStream is = cl.getResourceAsStream("com/gwt/agenda/GWTAgendaSample.properties");
props.load(is);
// Load the database access information
databaseURL = props.getProperty("databaseURL");
databaseUser = props.getProperty("databaseUser");
databasePass = props.getProperty("databasePass");
} catch (Exception e) {
e.printStackTrace();
logger.error("Error loading GWTAgendaSample.properties file.", e);
}
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
// Connect to the database
connection = DriverManager.getConnection(databaseURL, databaseUser, databasePass);
} catch (SQLException se) { messageOut = "Unable to connect to database. Exception message: " + se.getMessage();
System.out.println(messageOut);
se.printStackTrace();
// Server side log
logger.error(messageOut + "\n", se);
destroy();
} catch (Exception e) {
messageOut = "Unable to connect to database. Exception message: " + e.getMessage();
System.out.println(messageOut);
e.printStackTrace();
// Server side
logger.error(messageOut + "\n", e);
destroy();
}
}
有人能给我指一下正确的方向吗。
我错过什么了吗
请帮忙
编辑
无法连接到数据库。
异常消息:侦听器被拒绝
与以下内容的连接
错误:ORA-12505,TNS:listener没有
目前不知道中给出的SID
连接描述符
通常,当我的DB URL对相关驱动程序的格式不正确,或者我的用户名和密码不正确或传递不正确时,我会看到这种情况
我要做的是使用IDE的db插件和我的代码将使用的相同驱动程序连接到db,并在尝试通过代码连接之前使其工作。此错误发生在以下情况下: 未配置TNS侦听器 TNS Listerner出现混乱但未运行 连接URL中的TNS名称错误 系统路径中有多个TNSNAMES.ORA 我和甲骨文玩得很开心。
请尝试验证您的数据库是否已启动并正在运行连接器。听起来您的连接被Oracle数据库拒绝。您确定您的Oracle数据库已启动并正在运行吗?很久以前我也遇到过类似的问题,我认为没有必要安装MYSQL数据库来运行示例。我错了,必须安装才能让它运行 这是谷歌应用程序引擎的问题。在外部服务器上运行应用程序 这里是有用的链接
databaseURL=jdbc:oracle:thin:@hp PC:1521:Agenda databaseUser=user databasePass=Agenda其中@hp PC是我的计算机名,Agenda是我的数据库名oracle侦听器是否已启动并运行?如何测试它?您的建议是什么?您应该检查侦听器是否已启动,以及它是否正在侦听端口1521,原因是:java.net.ConnectException:连接被拒绝:connect。从控制台尝试netstat-a,查看端口1521是否为openHi,我已尝试并获得以下协议:TCP//本地网络:127.0.0.1:8888//外部:hp PC:0//状态:正在侦听。找不到任何名为1521的端口。我看到了很多Acivate行和状态建立。不知道这是否应该发生。我记得我很久以前编辑过我的主机文件。这是问题的原因吗?提前感谢,我已经编辑并发布了警告和错误。也许这有助于理解错误的原因。您的错误表明它无法识别SID。对不起,我不太明白怎么做。我打开DOS窗口并执行ping操作,然后其他参数是什么?谢谢。C:\oraclexe\app\oracle\product\10.2.0\server\network\admin\sqlnet.ora使用主机名适配器解析别名试图联系DESCRIPTION=CONNCET\u DATA=SERVICE\u NAME=address=PROTOCOL=TCPHOST=127.0.0.1PORT=1521确定10毫秒是否正确?我缺少一个SERVICE\u NAME,但我不是oracle专业人员。可能是主机名必须是主机名,否则连接可能限制为localhost。我的数据库名为Agenda.sql,位于我的项目中的com.gwt.Agenda下。我没有提到它!它应该在连接字符串中引用它的名称/位置?我还有一个file.properties,其中包含参数surl、user、pass,它们是:databaseURL=jdbc:oracle:thin:@hp PC:1521/XE-databaseUser=marantes-databasePass=Cepsa2000。这是否也是正确的,或者必须将数据库URL与URL、pass和user连接起来?我认为问题不在您的URL内。它在服务器的配置中。作为一名开发人员,我对客户机部分有所了解,但我对配置Oracle服务器的了解不是很好。您必须询问Oracle管理员。试着问你一个错误的问题。你是对的。尚未安装Oracle数据库。我从没想过这是必要的。这就是它给出错误的原因。一旦安装了Postgres数据库并修改了代码,它就可以在没有不需要的工件的情况下工作。谢谢
Unable to connect to database. Exception message: Erro de E/S: The Network Adapter could not establish the connection
java.sql.SQLRecoverableException: Erro de E/S: The Network Adapter could not establish the connection
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:536)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.gwt.Agenda.server.GreetingServiceImpl.init(GreetingServiceImpl.java:78)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:342)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:375)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:422)
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:678)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:238)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1054)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:308)
... 27 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:209)
at oracle.net.nt.ConnOption.connect(ConnOption.java:123)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:353)
... 32 more