Informix java.lang.ClassNotFoundException: com.informix.jdbc.IfxDirectConnection - java

I'm trying to install and connect to a local Informix 14 for testing on Windows 10. My maven POM has:
<dependency>
<groupId>com.ibm.informix</groupId>
<artifactId>informix-jdbc-complete</artifactId>
<version>4.50.4.1</version>
<scope>test</scope>
</dependency>
I'm trying direct connection
database.url = jdbc:informix-direct://sysmaster
database.driver=com.informix.jdbc.IfxDirectConnection
But I'm getting class not found.
Any ideas?

You shouldn't use 'jdbc:informix-direct:'. That was reserved for UDR written in Java.
Use "jdbc:informix-sqli", something like:
Class.forName("com.informix.jdbc.IfxDriver");
conn = DriverManager.getConnection("jdbc:informix-sqli://420ito:9088/stores7:INFORMIXSERVER=ids1410;user=informix;password=mypassword;");

Related

Maven: No suitable driver found for jdbc::mysql://google

I'm trying to connect my Java Maven project (which runs on a Jetty server) to a Google Cloud MySQL Database with the following code:
private static final String CREDENTIALS_STRING = "jdbc::mysql://google/weatherplanning?cloudSqlInstance=csci310-project-2:us-central1:myinstance&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false&user=xxxx&password=xxxx";
try {
System.out.println("Connecting to database...");
Class.forName("com.mysql.cj.jdbc.Driver");
connection = DriverManager.getConnection(CREDENTIALS_STRING);
} catch (SQLException | ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I've included both of these dependencies in my pom.xml:
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory-connector-j-8</artifactId>
<version>1.0.15</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.18</version>
</dependency>
I'm getting
java.sql.SQLException: No suitable driver found for jdbc::mysql://google...
and I don't know what to do. I assume the dependencies should handle adding the JDBC driver to my classpath.
Your problem looks like you have a typo in your JDBC url. Your URL should start with jdbc:mysql instead of jdbc::mysql.
Additionally, you should always use a connection pool (like Hikari). Connection pools have many benefits, including better error handling, exponential backoff, and reduced latency.
You can view Hikari being used with the Cloud SQL JDBC socket factory in the context of a web application in this sample. Full instructions for deploying it are in the sample's README.

Errors trying to start ZetaSQL planner

I'm trying to run a Beam pipeline with SQL transforms, parsed with ZetaSQL. I begin with setting options with
options.setPlannerName("org.apache.beam.sdk.extensions.sql.zetasql.ZetaSQLQueryPlanner");
When I try creating my SqlTransform with any given query, I get
java.util.ServiceConfigurationError: org.apache.beam.repackaged.sql.com.google.zetasql.ClientChannelProvider: Provider org.apache.beam.repackaged.sql.com.google.zetasql.JniChannelProvider could not be instantiated
at java.util.ServiceLoader.fail (ServiceLoader.java:232)
at java.util.ServiceLoader.access$100 (ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService (ServiceLoader.java:384)
at java.util.ServiceLoader$LazyIterator.next (ServiceLoader.java:404)
at java.util.ServiceLoader$1.next (ServiceLoader.java:480)
at org.apache.beam.repackaged.sql.com.google.zetasql.ClientChannelProvider.loadChannel (ClientChannelProvider.java:31)
...
at org.apache.beam.sdk.extensions.sql.SqlTransform.expand (SqlTransform.java:82)
at org.apache.beam.sdk.Pipeline.applyInternal (Pipeline.java:539)
at org.apache.beam.sdk.Pipeline.applyTransform (Pipeline.java:473)
at org.apache.beam.sdk.values.PCollection.apply (PCollection.java:357)
...
I've added the following relevant dependencies to my POM in maven:
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
<version>2.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-sdks-java-extensions-sql</artifactId>
<version>2.16.0</version>
</dependency>
Is there something else I'm missing here?
Unfortunately the ZetaSQL planner will today not work from a MAC, or older versions of Linux. Please see the comment from Rui in:
ZetaSQL Sample Using Apache beam
Looks like this PR maybe useful here ( I have not dug deeply into this to confirm):
https://github.com/google/zetasql/pull/3
As a workaround could you try on a newer version of linux? Maybe in a container?
This is resolved in the latest version of ZetaSQL, which will be used with Beam 2.21. You can also try pulling down a newer version of ZetaSQL (at least 2020.03.2):
<dependency>
<groupId>com.google.zetasql</groupId>
<artifactId>zetasql-jni-channel</artifactId>
<version>2020.03.2</version>
</dependency>

SchemaCrawler error when adding MariaDB artifact

When I add this to the pom.xml:
<!-- https://mvnrepository.com/artifact/us.fatehi/schemacrawler-mariadb -->
<dependency>
<groupId>us.fatehi</groupId>
<artifactId>schemacrawler-mariadb</artifactId>
<version>14.08.06</version>
</dependency>
Then I get an error:
java.util.ServiceConfigurationError: schemacrawler.tools.databaseconnector.DatabaseConnector: Provider schemacrawler.server.mariadb.MariaDBDatabaseConnector could not be instantiated
..
Caused by: java.lang.NoSuchMethodError: schemacrawler.tools.databaseconnector.DatabaseConnector.<init>(Lschemacrawler/tools/databaseconnector/DatabaseServerType;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
I am trying to connect to an Oracle database. This works if I omit MariaDb from the pom.
I am using a higher version of SchemaCrawler:
<dependency>
<groupId>us.fatehi</groupId>
<artifactId>schemacrawler</artifactId>
<version>14.21.02</version>
</dependency>
<!-- https://mvnrepository.com/artifact/us.fatehi/schemacrawler-oracle -->
<dependency>
<groupId>us.fatehi</groupId>
<artifactId>schemacrawler-oracle</artifactId>
<version>14.21.02</version>
</dependency>
I would like to have the MariaDB in the pom.xml and still be able to read Oracle with SchemaCrawler. The error occurs after connecting to the database, in the last line of the following code:
Connection dbConnection = DatabaseBroker.getDbConnection(
eventName,
cbDatabase.getValue(),
tConnectionString.getValue(),
tUsername.getValue(),
tPassword.getValue()
);
//Schema schema = SchemaCrawler.getSchema(dbConnection, SchemaInfoLevel.detailed(), new SchemaCrawlerOptions());
//SchemaCrawler sc = new SchemaCrawler(dbConnection, null);
try
{
Catalog catalog = SchemaCrawlerUtility.getCatalog(dbConnection, null);
You are using incompatible versions of the main SchemaCrawler library and a SchemaCrawler database plugin. You do not need a plugin for MariaDB if you are connecting to Oracle. In fact, SchemaCrawler will work with most databases even without a SchemaCrawler database plugin on the classpath.

org.apache.hive.service.cli.HiveSQLException: java.lang.NoClassDefFoundError: org/apache/hadoop/ipc/CallerContext$Builder

I am trying to connect my hive jdbc client to hiveserver2.
i am using following maven
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-service</artifactId>
<version>1.2.1000.2.4.2.12-1</version>
</dependency>
hiveserver2.start() started my hiveserver2.
but when i start my jdbc client with followin code :
val con: Connection = DriverManager
.getConnection("jdbc:hive2://localhost:10000/default", "", "")
val stmt: Statement = con.createStatement
stmt.execute("create table if not exists student (id int))
it gives me following exception :
org.apache.hive.service.cli.HiveSQLException:
java.lang.NoClassDefFoundError:
org/apache/hadoop/ipc/CallerContext$Builder at
org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:256) at
org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:242) at
org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:254)
Can anybody either help me to identify the reason of this or solution please.
Thanks in advance.
This could happen due to multiple reason:-
Either the corresponding jar wont be available which is the
hivejdbcdriver jar with the right version eg: "hive-jdbc-1.2.1.jar"
or sometimes you may to use
"hive-jdbc-1.2.1-standalone.jar"(depending upon on how your usecase
is) in the libraries folder or .m2 repository.
Or,it could also
be the jar may not be added in your classpath(add an entry for this
jar in your .classpath file), depending upon how your application is
built.

Run test in IDE NetBeans

I'm sorry but I'm studying
Faced with the problem on test runs from IDE to FF 32. On Virtual Machine (VirtualBox) tests are run (where I run the selenium-server-standalone-2.43.0) everything OK!!!
And start with IDE Netbeans, just open a browser and nothing else happens. After the test falls
Failed to connect to binary FirefoxBinary (/ usr / bin / firefox) on port 7055; process output follows
But the / usr / bin / firefox looked there present binary
Sin on the fact that in my pom file is connected firefox-driver-2.42.2 (2.43.0 connect but does not work with the source code repository tightened http: //repo1.maven.o...org/seleniumhq/ and I NetBeans sees only the latest version 2.42.2 jar and 2.43.0 pom)
Also tried to connect firefox-driver-2.43.0 pom nothing has changed.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.43.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.43.0</version>
<type>pom</type>
</dependency>

Categories