I am able to connect to database using PL/SQL developer.
But, when I am not able to connect to database using DriverManager.getConnection(databaseUrl, idUser, password);
I am getting this error
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
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:673)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:715)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
Related
I wish to use Hikari Connection Pool in my Spring application to connect to the Oracle Database
Below is the connection string
JDBC URL:
jdbc:oracle:thin:#ldaps://abc-def-dmz.demo.com:876/SOM_APP,cn=oraclecontext,dc=demo,dc=com
Getting the following error
Error Message: Failed to initialize pool: IO Error: JNDI Package
failure javax.naming.CommunicationException: localhost:876[Root
exception is java.net.ConnectException: Connection refused: connect]
How do I fix this?
java.net.ConnectException: Connection refused: connect
The error implies that your connection is being blocked, most likely by a firewall. Check with your DBA and system or network administrators to make sure the network path to the server is open, and that you are using the right port numbers.
I have a database on external server with Cpanel. I've made database and all I know is that this is database adress: server: pgsql1.superhost.pl
I tried to connect like this:
connection = DriverManager.getConnection(
"jdbc:postgresql://sql1.superhost.pl:5432/database_name",
"user_name", "password");
I tried without port, I tried everything, but I'm still getting error:
org.postgresql.util.PSQLException: at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:233)
....
Caused by: java.net.UnknownHostException: sql1.superhost.pl
I am trying to connect to a remote db2 database using the db2 jdbc drivers and am getting a sockertimeout error. I have deployed to two different machines and on the second machine I don't get the error. I'm thinking that this could be something to do with a network connection to the box that my db2 database is on.
Can anyone help me with ways that I can try and debug this error. So far the only think I can come up with is to use tracert hostname to compare the number of hops on the box that the connection works and on the one that it does not.
thanks
[11/5/14 14:22:46:537 EST] 0000d296 SystemErr R Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:413)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:274)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:261)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:389)
at java.net.Socket.connect(Socket.java:556)
at com.ibm.db2.jcc.a.y.run(y.java:34)
at java.security.AccessController.doPrivileged(AccessController.java:241)
at com.ibm.db2.jcc.a.xb.a(xb.java:390)
at com.ibm.db2.jcc.a.xb.<init>(xb.java:79)
at com.ibm.db2.jcc.a.a.x(a.java:265)
at com.ibm.db2.jcc.a.b.a(b.java:1781)
at com.ibm.db2.jcc.b.bb.a(bb.java:394)
at com.ibm.db2.jcc.b.bb.<init>(bb.java:354)
at com.ibm.db2.jcc.a.b.<init>(b.java:314)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:572)
at java.sql.DriverManager.getConnection(DriverManager.java:196)
at com.myer.epostools.db.DBUtility.createConnection(DBUtility.java:18)
at com.myer.eposweb.dao.BaseDAO.getConnection(BaseDAO.java:36)
I am not able to connect to oracle Database from my machine , but can connect to same DB through SQL developer. I am getting the following exception
java.sql.SQLRecoverableException: IO Error: Connection reset by peer:
socket write error at
oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:428) at
oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:536)
at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:228)
at
oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521) at
oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:280)
at
oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:207)
at
oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:157)
at OrgHierarchy.DBTest.main(DBTest.java:39)
I can also telnet to same DB URL and port.
Other Details: Windows XP , Oracle 11g 11.0.2
thanks.
Im getting
I/O Error: DB server closed connection.
while connecting to MS SQL server 2008 from java code .
SQL server is in mixed mode and its in local machine.My connection string is
jTDS
jdbc:jtds:sqlserver://machineName:1433;databaseName=DB;integratedSecurity=true
stack trace is
java.sql.SQLException: I/O Error: DB server closed connection.
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2311)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:610)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.(ConnectionJDBC2.java:345)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.app.hibernate.test.(test.java:22)
at com.app.hibernate.test.main(test.java:53)
Caused by: java.io.IOException: DB server closed connection.
at net.sourceforge.jtds.jdbc.SharedSocket.readPacket(SharedSocket.java:848)
at net.sourceforge.jtds.jdbc.SharedSocket.getNetPacket(SharedSocket.java:727)
at net.sourceforge.jtds.jdbc.ResponseStream.getPacket(ResponseStream.java:466)
at net.sourceforge.jtds.jdbc.ResponseStream.read(ResponseStream.java:103)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2206)
... 8 more
Exception in thread "main" java.lang.NullPointerException
at com.app.hibernate.test.db(test.java:36)
at com.app.hibernate.test.main(test.java:54)
JDBC Driver
String url ="jdbc:sqlserver://machine:1433;instance=SQLEXPRESS;databaseName=db";
stacktrace
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'username'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:156)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:240)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:78)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2636)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2046)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2034)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4003)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1550)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1207)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(SQLServerConnection.java:1054)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:758)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.app.hibernate.test.(test.java:22)
at com.app.hibernate.test.main(test.java:53)
Exception in thread "main" java.lang.NullPointerException
at com.app.hibernate.test.db(test.java:36)
at com.app.hibernate.test.main(test.java:54)
Your Connection String and authentication have errors. if it is mix mode don't use SQL authentication
Try this
PC Name : janaka-pc SQL User Name : sa SQL Password
: 1234 Database : Janak_DB
Code for sql Conncetion in JDBC
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://janaka-PC;user=sa;password=1234;database=Janak_DB");
You have problems in your connection strings
For jTDS:
jdbc:jtds:sqlserver://machineName:1433;databaseName=DB;useNTLMv2=true;domain=workgroup
You may read http://jtds.sourceforge.net/faq.html#windowsAuth for the required Single-Sign-On library for NTLM to work.
"integratedSecurity=true" that you supplied for jdts is valid when using the JDBC driver
jdbc:sqlserver://machine:1433;instance=SQLEXPRESS;databaseName=db;integratedSecurity=true
You have an authentication error in on the MS SQL side.
If you're not in control of how to adquire the connection (ie, you're using a Datasource or a Connection Pool), the connection URL must contain the login and password to be used, like:
jdbc:sqlserver://machine:1433;instance=SQLEXPRESS;databaseName=db;user=USERNAME;password=PASSWORD";
If the application is running on a Windows machine and you want to use the credentials of the logged user, then you can specify the domain parameter with or without useNTLMv2.
Finally, if you are on a windows machine but you want to authenticate the user against a domain, then you must supply the username, password and domain parameters. You can read all about it in the jtds FAQ, specially the URL Format section.