Unable to Connect to Oracle Database 11g via JDBC - java

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.

Related

JDBC can't connect to SQL Server / Azure SQL Database

I use
JTDS version: jtds-1.3.1
MS SQL JDBC version: mssql-jdbc-8.4.0.jre8 even mssql-jdbc-9.2.0.jre8
Java 8 Update 251
For simplicity, the code will the same as:
Android studio can't connect to database in Azure sql server
I have a problem to connect to SQL Server or Azure SQL.
I want to connect with this syntax:
val connectionString = "jdbc:jtds:sqlserver://192.168.xx.xx:1433;databaseName=myData;user=x1;password=p1;encrypt=true;trustServerCertificate=true;"
With this JTDS connection string, I can connect to my SQL Server DB on localhost, but with MS-JDBC, I failed to connect.
val connectionString = "jdbc:sqlserver://192.168.xx.xx:1433;databaseName=myData;user=x1;password=p1;encrypt=true;trustServerCertificate=true;"
I get the following errors:
com.microsoft.sqlserver.jdbc.SQLServerException: The Driver could not
establish a secured connection to SQL Server by using Secure Sockets
Layer (SSL) encryption. Error: "Socket is closed". ClientConnectionId:
xxxxxxxxxxxxxxxxx
An interesting thing happens when I connect with JTDS version to SQL Azure with the command:
jdbc:jtds:sqlserver://xxxxx.database.windows.net:1433;database=xxxxx;user=username;password=password;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
I failed to connect to SQL Azure with the following errors
java.sql.SQLException: Reason: Login Failed due to client TLS Version
being less than minimal TLS Version allowed by the server
I already tried:
SSLProtocol=TLSv1.2 (TLS, TLSv1.0, TLSv1.1) => none work
ssl=require
Is it a bug with JTDS, a bug with JDBC, o isr my connection string invalid? I can connect to SQL Azure with my dotnet apps (C#).
I just fixed this in an Azure Managed Instance using the PowerShell script below:
Set-AzSqlInstance -Name 'InstanceName' -ResourceGroupName 'ResourceGroupName' -MinimalTlsVersion "None" -force

Sql server jdbc driver trying to connect via wrong username. JDBC using integrated security/windows authentication and username,password

I have upgrade from JTDS driver to Sql server JDBC driver 4.1 and trying to connect to Sql server database using following connection string
jdbc:sqlserver://<System_IP>;instance=MSSQLSERVER;domain=domainname;IntegratedSecurity=true;sendStringParametersAsUnicode=false;selectMethod=cursor;user=administrator;password=pass
It's failing with error message:
Login failed for user domainname/current_machinename.
This connection was working fine till I upgraded to JDBC driver 4.1
Why JDBC is trying to connect via domainname/current_machinename. It should have been domainname/administrator which I am passing in connection string.

Hive-Java(jdbc) connection problems

I'm trying to connect with hive via jdbc but it gives me the following exception
java.sql.SQLException: org.apache.thrift.transport.TTransportException
I already have running hadoop and derby. By the console of hive (in linux) I can work but once I try it for the project in java it does not work
Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver");
Connection co = DriverManager.getConnection("jdbc:hive://localhost:9000/almacendb", "","");

Getting JDBC drivers compatibility issue. java.sql.SQLException: ORA-06413: Connection not open

I am getting below exception with Oracle JDBC ojdbc14_g.jar drivers:
java.sql.SQLException: ORA-06413: Connection not open.
My Oracle version is:
My machine and server details are:
I am able to connect to production DB from my development environment, but after installing application in production server my application is unable to connect to locally installed database. I am getting above said exception.
Below is my connection URL:
jdbc:oracle:oci8:#127.0.0.1:1521:XE
Try to replace oci8 with thin. JDBC over (native) OCI require some knowledge and experience. You have to install and configure Oracle client 1st.
See http://docs.oracle.com/cd/B28359_01/java.111/b31224/instclnt.htm

Create connection to SQL Server 2008 in Jaspersoft iReport Designer 4.0.2?

I cannot create connection to SQL Server 2008 with Jaspersoft iReport designer 4.0.2..
When I test my connection I got an error
SQL problems: The TCP/IP connection to the host has failed.
java.net.ConnectException: Connection refused: connect
jdbc:sqlserver://localhost:1433;databaseName=qlks
qlks is my database name.
I use JDBC Driver :MS SQLServer (2005) (com.microsoft.sqlserver.jdbc.SQLServerDriver)
JDBC URL : jdbc:sqlserver://localhost:1433;databaseName=qlks
I entered my username and password.
please help me!
I need it for my Java project at school!
Thanks!

Categories

Resources