Getting connection error from Flyway command line with DB2 drivers - java

We are in the process of upgrading our database version from DB2 11.1.3 to DB2 11.5.6. We have been using Flyway for 4 years for migrating our code. The version we are using is 5.1.3 and it is working well, except it throws a warning the DB2 11.5 is not supported.
I have downloaded and tried to use Flyway 7.13.0 and 7.15.0 in our process but they both throw the following error
ERROR: Unable to obtain connection from database (jdbc:db2://VAN-FCALLANDER:50000/TMLCLCUR:retrieveMessagesFromServerOnGetMessage=true;) for user 'TMWIN': [jcc][10214][10050][4.29.24] java.util.Properties object passed to java.sql.Driver.connect() cannot be overridden by URL: jdbc:db2://VAN-FCALLANDER:50000/TMLCLCUR:retrieveMessagesFromServerOnGetMessage=true;. ERRORCODE=-4461, SQLSTATE=42815
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL State : 42815
Error Code : -4461
Message : [jcc][10214][10050][4.29.24] java.util.Properties object passed to java.sql.Driver.connect() cannot be overridden by URL: jdbc:db2://VAN-FCALLANDER:50000/TMLCLCUR:retrieveMessagesFromServerOnGetMessage=true;. ERRORCODE=-4461, SQLSTATE=42815
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][10214][10050][4.29.24] java.util.Properties object passed to java.sql.Driver.connect() cannot be overridden by URL: jdbc:db2://VAN-FCALLANDER:50000/TMLCLCUR:retrieveMessagesFromServerOnGetMessage=true;. ERRORCODE=-4461, SQLSTATE=42815
According to IBM, the error being returned is from the way the parameter is set by Flyway. https://www.ibm.com/docs/en/db2/11.5?topic=errors-errorcode-4461
I have tried using both the 11.1 (type3) driver and the 11.5 (type4) driver and both are throwing the same message.
Any idea how to get around this without updating the actual Flyway code the way IBM suggests?

Looks like the Flyway code may need some change.
Check their issues page and open a ticket if a ticket does not already exist there.
Otherwise there are possible workarounds for now.
In your specific case, the attribute appended to the URL triggers the exception so you can try:
(1) Change the flyway.url to remove :retrieveMessagesFromServerOnGetMessage=true
(2) Change the flyway config to supply this property via the fltway.jdbcProperties (or equivalent method) if that is enabled in your flyway version: flyway.jdbcProperties.retrieveMessagesFromServerOnGetMessage=true . See docs
https://flywaydb.org/documentation/configuration/parameters/jdbcProperties
or
(3) externally configure the connection property that you need via the IBM db2dsdriver.cfg. See the IBM Db2 documentation for details. The idea is that you can put all (or some of) the Data Source Name details and parameters into an XML file (db2dsdriver.cfg) and the Db2 driver will parse that at runtime to carry out your instructions.
or
(4) remove the property from the URL and suffer the absence of detailed messages on errors until the flyway code gets fixed.

Related

H2 Database Database to Lower Not Valid Connection Setting (2019)

I'm trying to connect to an embedded H2 database with the compatibility mode for PostgreSQL. I'm using the settings as described in the online documentation:
jdbc:h2:~/test.h2.db;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE
I'm getting the error:
Unsupported connection setting "DATABASE_TO_LOWER"
Is this still an experimental setting? Is there a solution and/or workaround for this error?
H2 Database v.1.4.199 + Java 11.0.2 (Oracle)
It looks like you have multiple versions of H2 in your classpath and wrong version is actually used. You can check the complete error message to be sure.
For example, version 1.4.197 throws
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Unsupported connection setting "DATABASE_TO_LOWER" [90113-197]
A 197 indicates a database version.
1.4.199 accepts your URL properly.
Also note that database path in the URL shouldn't include a file name extension. With ~/test.h2.db the file test.h2.db.mv.db will be actually used.
Please visit http://www.h2database.com/html/changelog.html
PR #1776: Improve DATABASE_TO_LOWER handling
Try to update your h2 version from 1.4.199
Warning : By default H2 transforms all names into uppercase (ex: fromIP => FROMIP). This setting will pass everything in lowercase but will not keep the case (ex: fromIP => fromip)

Error connecting to Microsoft SQL Server in IBM IIB via JDBC

I cannot connect to Microsoft SQL Server v. 2008 in Websphere IIB (formerly, Message Broker) with a JDBC provider.
I've created the provider according to the IBM documentation - Setting up a JDBC provider for type 4 connections and specified a valid security identity.
I've also tried using the latest versions of sqljdbc4.jar and sqljdbc41.jar from Microsoft.
I'm trying to get the connection using:
Connection conn = getJDBCType4Connection(THE_NAME_OF_THE_PROVIDER,JDBC_TransactionType.MB_TRANSACTION_AUTO)
I get the following error trace:
Exception details: message: java.lang.ExceptionInInitializerError stack trace: [java.lang.J9VMInternals.initialize(J9VMInternals.java:259)
javax.crypto.KeyAgreement.getInstance(Unknown Source)
com.ibm.jsse2.lb.g(lb.java:44)
com.ibm.jsse2.lb.a(lb.java:108)
com.ibm.jsse2.l$c_.a(l$c_.java:6)
com.ibm.jsse2.l.a(l.java:80)
com.ibm.jsse2.m.a(m.java:15)
com.ibm.jsse2.m.h(m.java:13)
com.ibm.jsse2.qc.a(qc.java:38)
com.ibm.jsse2.qc.<init>(qc.java:632)
com.ibm.jsse2.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:16)
com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1606)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1324)
com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:992)
com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:828)
com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnectionInternal(SQLServerDataSource.java:629)
com.microsoft.sqlserver.jdbc.SQLServerPooledConnection.createNewConnection(SQLServerPooledConnection.java:60)
com.microsoft.sqlserver.jdbc.SQLServerPooledConnection.<init>(SQLServerPooledConnection.java:42)
com.microsoft.sqlserver.jdbc.SQLServerXAConnection.<init>(SQLServerXAConnection.java:30)
com.microsoft.sqlserver.jdbc.SQLServerXADataSource.getXAConnection(SQLServerXADataSource.java:51)
com.ibm.broker.jdbctype4.jdbcdbasemgr.JDBCType4Connection.createXAConnection(JDBCType4Connection.java:244)
com.ibm.broker.jdbctype4.jdbcdbasemgr.JDBCType4DatabaseManager.getThreadOwnedConnections(JDBCType4DatabaseManager.java:308)
com.ibm.broker.jdbctype4.localtrxn.JDBCType4SinglePhaseTrxnHandler.getConnection(JDBCType4SinglePhaseTrxnHandler.java:262)
com.ibm.broker.jdbctype4.localtrxn.JDBCType4SinglePhaseTrxnHandler.getConnection(JDBCType4SinglePhaseTrxnHandler.java:154)
com.ibm.broker.jdbctype4.connfact.JDBCType4ConnectionFactory.getConnection(JDBCType4ConnectionFactory.java:163)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:94)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
java.lang.reflect.Method.invoke(Method.java:619)
com.ibm.broker.plugin.MbNode.getJDBCType4Connection(MbNode.java:1575)
ru.cinimex.fr2back.FR2BACK_DB_InsertMessage_JavaCompute.fillInCache(FR2BACK_DB_InsertMessage_JavaCompute.java:115)
ru.cinimex.fr2back.FR2BACK_DB_InsertMessage_JavaCompute.createCache(FR2BACK_DB_InsertMessage_JavaCompute.java:102)
ru.cinimex.fr2back.FR2BACK_DB_InsertMessage_JavaCompute.evaluate(FR2BACK_DB_InsertMessage_JavaCompute.java:38)
com.ibm.broker.javacompute.MbRuntimeJavaComputeNode.evaluate(MbRuntimeJavaComputeNode.java:339)
com.ibm.broker.plugin.MbNode.evaluate(MbNode.java:1491)
I think the SQL server driver is trying to use SSL which comes into a conflict with IBM's Java. Is there a way to prevent it from using SSL at all?
When I'm doing the same thing with an Oracle database, everything works well.
It's a requirement to use JDBC and not IIB's native ODBC drivers.
If you want to disable the Microsoft JDBC Driver's use of SSL, it should be possible to do so by setting the "encrypt" data source property to a value of false.
https://msdn.microsoft.com/en-us/library/bb879920%28v=sql.110%29.aspx
The above would apply if you were programmatically creating & configuring the data source. In the case where there is intermediate code handling that, it's likely there would be somewhere to specify name/value pairs of data source properties, for example, in data source configuration or on an API that you are using. Is there anywhere that you have the opportunity to do that? If this were a WebSphere Application Server data source, it would either be in data source custom properties (traditional) or properties.microsoft.sqlserver element nested under dataSource in server.xml (Liberty).

Exception while connecting to DB2 in java using JDBC

I am trying to connect to a db2 database in Java. Below the driver and the connection string and the driver details i am giving
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
String url="jdbc:db2://hostname:portnumber/databasename";
sourceConnection=DriverManager.getConnection(url,"username","password");
But I am getting the below exception
"COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0615E Error receiving from socket, server is not responding. SQLSTATE=08S01"
I also tried changing the connection string to
String url="jdbc:db2:hostname:portnumber/databasename";
Still it is resulting the same exception above while trying to get the Connection.
And i have tried the below option also using JDBC app driver
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
DB2DataSource db2ds = new DB2DataSource();
db2ds.setServerName("hostname");
db2ds.setPortNumber(portnumber);
db2ds.setDatabaseName("databasename");
db2ds.setUser("username");
db2ds.setPassword("password");
sourceConnection=db2ds.getConnection();
For the above two connection I used the jar "db2java.jar"
And i have tried using the JCC driver:
Class.forName("com.ibm.db2.jcc.DB2Driver");
String url="jdbc:db2://hostname:portnumber/databasename";
sourceConnection=DriverManager.getConnection(url,"username","password");
For this connection i have added the below jars
1)db2jcc.jar
2)db2jcc_license_cu.jar
This time around I am getting the below error,
"com.ibm.db2.jcc.am.go: [jcc][t4][201][11237][3.57.82] Connection authorization failure occurred.
Reason: Security mechanism not supported. ERRORCODE=-4214, SQLSTATE=28000"
I tried to connect to the same db2 source using "Quest for DB2" tool and the connection was successful.
Am i missing something in the code and is it a problem with DB2 drivers or connection string?
Can someone please guide me.
Thanks in advance.
Cause:
If the DB2® instance where InfoSphere Optim Performance Manager is running has the authentication configuration parameter set to DATA_ENCRYPT, you cannot log in to the web console.
Resolving the problem:
Do the following steps:
On the DB2 instance where Optim Performance Manager is running, set the authentication configuration parameter to SERVER by issuing the following command:
db2 update dbm cfg using authentication server
Restart the DB2 instance and InfoSphere Optim Performance Manager.
For more details visit here.
Your first two attempts were not supposed to work. You're using the JCC driver URL format, so it wouldn't be valid for either "net" or "app" drivers, which are deprecated anyway.
Use the JCC driver (com.ibm.db2.jcc.DB2Driver) and the URL format of "jdbc:db2://hostname:portnumber/databasename" and see this technote for the solution to the "Security mechanism not supported" problem. In short, you need to use a supported JDK.

Oracle error messages

I'm curious about something... is it possible for an Oracle 11 instance to be configured so that it does not return any ORA-?????? error messages?
I've issued many invalid queries where I've misspelled column names, table names... things where I would expect an ORA error message.
Say for security purposes say if a stray java stack trace got exposed to a browser could you force oracle to always show the same bogus error message in the stack trace?
I always get this one:java.sql.SQLException: IO Error: Size Data Unit (SDU) mismatch
I've googled that error up and down, and I do not have any connection or database configuration issues at all! I get it on a per-query basis.
Not a direct solution but I was having the same problem with the SDU mismatch masking the real error. I found a link (http://www.rajivnarula.com/blog/2013/03/13/table-not-found-or-error-not-found/) that gave an indirect way to expose the error:
I tried swapping the JDBC driver with the older ojdbc14.jar and voila
! The real error was exposed : Good old
ORA-00942 (table or view does not exist)
Once I put the table in- everything works fine- with ojdbc14.jar as
well ojdbc6.jar
Obviously a pain but useful until someone posts a way to get the underlying error with the newer driver...
Basically your setup is not correct. Either on the client or on the server or on both the sdu size has been set and they do not match between client and server. The sdu size can be set on the client in
the sqlnet.ora file or
in the connect descriptor
On the server it can be set with
in the sqlnet.ora file
the dispatchers init.ora parameter
or the listener.ora file.
If you are still not convinced, trace the tns traffic to verify this. Client side tracing can be enabled by adding the following settings to the sqlnet.ora file:
trace_level_client = 10
trace_unique_client = on
trace_file_client = sqlnet.trc
trace_directory_client = <path_to_trace_dir>
Server side settings can be enabled with the following settings:
trace_level_server = 10
trace_file_server = server.trc
trace_directory_server = <path_to_trace_dir>
If level 10 is not sufficient, set the level to 16. This will create a trace file that you can analyze.
You can try to upgrade the Oracle 11g JDBC driver to a version greater than 11.2.0.3.0, as described here
There is another chance whether the table in the query exists in the database or not. Check for table name in the query or try whether you are trying for Oracle Database using mysql driver

setting Client Info in JDBC for Oracle

I have a Java application which needs to be audited (so obviously I need a way in which the app can be identified with the application name). I googled and found that ojdbc14 has the method .setClientInfo which allows registering the application with a customized name, so I am trying to get it work but I get the following error:
Exception in thread "main" java.lang.AbstractMethodError:
oracle.jdbc.driver.T4CConnection.setClientInfo(Ljava/lang/String;Ljava/lang/String;)V
I am using ojdbc14 with oracle 10g express. If I do not set the line:
connection.setClientInfo("ApplicationName","Customers");
it works pretty well ....and by checking the audit info I can see that oracle gets the application name:OS_program_name=JDBC Thin Client, but I need a way to change it for a customized name.
By uncommenting that line which is supposed to set the application name it returns the error above.
Per oracle documentation that method is available for a Connection object. Do you have any idea how to solve this issue?
For AbstractMethodError, please check Why do I get java.lang.AbstractMethodError when trying to load a blob in the db?
In order to distinguish your connections in Oracle you can use this sample code below:
Properties jdbcProperties = new Properties();
this.jdbcProperties.put("user", userName);
this.jdbcProperties.put("password", password);
this.jdbcProperties.put("v$session.program", "YourApplicationName");
DriverManager.getConnection(url, jdbcProperties);
then check v$session by grouping against program column for your connections..

Categories

Resources