I connect to my db2 database with following URL:
jdbc:db2://myhost:9999/mydb:sslConnection=true;sslTrustStoreLocation=/home/my name/somekey.jks
using squirrel.
Now I'm trying to connect from python using jaydebeapi using the same URL string but it fails with
jpype._exception. SqlSyntaxErrorExceptionPyRaisable: com.ibm.db2.jcc.am.SqlSyntaxErrorException:
[jcc][10165][10051][4.20.4] Invalid database URL syntax: jdbc:db2://myhost:9999/mydb:sslConnection=true;sslTrustStoreLocation=/home/my name/somekey.jks. ERRORCODE=-4461, SQLSTATE=42815
What is the recommended way to pass the key store file via jaydebeapi?
Related
I'm trying to get the data from my Oracle Database to a Databricks Cluster. But I think I'm doing it wrong:
On the cluster library I just installed the ojdbc8.jar and then after that I opened a notebook and did this to connect:
CREATE TABLE oracle_table
USING org.apache.spark.sql.jdbc
OPTIONS (
dbtable 'table_name',
driver 'oracle.jdbc.driver.OracleDriver',
user 'username',
password 'pasword',
url 'jdbc:oracle:thin://#<hostname>:1521/<db>')
And it says:
java.sql.SQLException: Invalid Oracle URL specified
Can someone help? I've been reading documentations but there's no clear instruction on how I should actually install this jar step by step. I might be using the wrong jar? Thanks!
I have managed to set this up in Python/PySpark as follows:
jdbcUrl = "jdbc:oracle:thin:#//hostName:port/databaseName"
connectionProperties = {
"user" : username,
"password" : password,
"driver" : "oracle.jdbc.driver.OracleDriver"
}
query = "(select * from mySchema.myTable )"
df = spark.read.jdbc(url=jdbcUrl, table=query1, properties=connectionProperties)
I am using the Oracle JDBC Thin Driver instantclient-basic-linux.x64-21.5.0.0.0, as available on the Oracle webpages. The current version is 21.7 I think, but it should work the same way.
Check this link to understand the two different notations for jdbc URLs
I'm trying to connect DB2 via JDBC.
I can connect successfully through the following:
Class.forName("com.ibm.db2.jcc.DB2Driver");
Connection connection = DriverManager.getConnection("jdbc:db2://127.0.0.1:50000/SAMPLE", "db2admin", "xxxxxxx");
But I want to use the connection string including user and password.
So I refer to https://www.ibm.com/docs/en/db2/11.5?topic=cdsudidsdjs-url-format-data-server-driver-jdbc-sqlj-type-4-connectivity
However, I can not connect to DB2 in this way.
Class.forName("com.ibm.db2.jcc.DB2Driver");
Connection connection = DriverManager.getConnection("jdbc:db2://127.0.0.1:50000/SAMPLE:user=db2admin;password=xxxxxxx");
The error message:
com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][10165][10051][4.29.24] Invalid database URL syntax: jdbc:db2://127.0.0.1:50000/SAMPLE:user=db2admin;password=xA123456. ERRORCODE=-4461, SQLSTATE=42815
This is my maven dependency:
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>jcc</artifactId>
<version>11.5.6.0</version>
</dependency>
I'm very confused. Can anyone provide a clue?
i'm trying to load from a local file into a db2 database using jdbc. the code looks like below:
stmt = jdbc.connection.prepareCall("call sysproc.db2load(....)")
stmt.regParameter(3, "load client from D:\\a.del of del insert into a")
but it doesn't work. The "SYSPROC.DB2LOAD" option is incompatible with the "CLIENT" option
so is there any way i can use jdbc to load local file into db2??
I'm trying to check if the oracle DB connection using the Keyword:
Connect To Database Using Custom Params
Following libraries are imported:
Database Library
JayDeBe API
This this is the connection string used:
'oracle.jdbc.driver.OracleDriver', 'jdbc:oracle:thin:#//DBHostname:Port/DBName', ['user', 'pass']
We do not get any response that can identify if the connection is established or rejected.
We see this message in RIDE:
'oracle.jdbc.driver.OracleDriver', 'jdbc:oracle:thin:#//DBHostName:Port/DBName', ['user', 'pass']
20170927 17:07:54.438 : INFO : Executing : Connect To Database Using Custom Params : jaydebeapi.connect(db_api_2.connect('oracle.jdbc.driver.OracleDriver', 'jdbc:oracle:thin:#//DBHostName:Port/DBName', ['user', 'pass']))
Can someone please help us?
We found the solution: In our case we have python 2.7(32bit) therefore we need the following:
1. Oracle Instant Client Downloads for Microsoft Windows (32-bit). you can download it from here: http://www.oracle.com/technetwork/topics/winsoft-085727.html
Set the variable path in environment variable for the Oracle Instant client.
Download cx_Oracle API (32bit- cx_Oracle-6.0.2-cp27-cp27m-win32.whl (md5) ) from the location:https://pypi.python.org/pypi/cx_Oracle/
Open command prompt and run: pip install cx_Orcle --upgrade
Open the RIDE and use the following keyword:
Connect To Database Using Custom Params cx_Oracle 'user', 'password', 'DBHOSTNAME:PORT/DBNAME'
I am stuck with connecting to Oracle DB, have read lots of stuff but no help on result.
I have remote Oracle DB, I am connecting to it using DBVisualizer setting connection like this:
DB Type : Oracle
Driver (jdbc) : Oracle thin
Database URL: jdbc:oracle:thin:#10.10.100.10:1521/VVV.LOCALDOMAIN
UserIdf: SomeUser
Pass: SomePass
Connection works ok.
What I do in Ruby is :
require 'oci8'
require 'dbi'
...
conn = OCI8.new('SomeUser','SomePass','//10.10.100.10:1521/VVV.LOCALDOMAIN')
...
What I get is:
ORA-12545: Connect failed because target host or object does not exist
oci8.c:360:in oci8lib.so
the third parameter needs to be the TNS hostname, if you use SQL plus it is also the third parameter in the connectstring, you can find it also in the tnsnames.ora file in the oracle maps
in SQLPlus : connect user/password#hostname;
in oci8 : conn = OCI8.new('SomeUser','SomePass',hostname)
Here a working sample, obfuscated the parameters of course
require 'oci8'
oci = OCI8.new('****','***','****.***')
oci.exec('select * from table') do |record|
puts record.join(',')
end