So I have a java program and am using the following driver
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
to try to read data from a SQL server 2012 database, but I get the
java.sql.SQLException: No suitable driver found for jdbc:sqlserver://localhost....
If I have a SQL server 2012 database, can I not use the com.microsoft.sqlserver.jdbc.SQLServerDriver driver? Any help will be greatly appreciated.
You might be missing the driver class and you should add that to your project.
Just a quick search on the Maven Central produces this:
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.4.0.jre8</version>
<scope>test</scope>
</dependency>
Assuming that you run Java 8 and Maven, you can add this as a dependency to your project.
Related
I'm trying to use Intersystems IRIS Database with
Quarkus, but I'm getting problems making it work
does anyone knows how to set up the Intersystems IRIS Database
on Quarkus ?
I did that on my pom.xml and also I added the jar
hibernate-iris-1.0.0.jar and intersystems-jdbc-3.2.0.jar but it's not working
<dependency>
<groupId>com.intersystems</groupId>
<artifactId>intersystems-jdbc</artifactId>
<version>3.2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/intersystems-jdbc-3.2.0.jar</systemPath>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-iris</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/hibernate-iris-1.0.0.jar</systemPath>
</dependency>
This is my application.properties
quarkus:
datasource:
db-kind: other
username: _system
password: *****
jdbc:
url: jdbc:IRIS://localhost:1972/USER
driver: com.intersystems.jdbc.IRISDriver
hibernate-orm:
dialect: org.hibernate.dialect.InterSystemsIRISDialect
jdbc:
timezone: UTC
I found the solution, to set up Intersystems IRIS on Quarkus you need to add manually the jar file, and also you need to set up the pom.xml also some setup from Intersystems was made as a java class. you can see the solution looking at my project on GitHub
this is the link: https://github.com/JoseAdemar/quarkus-project-with-intersystems-ris-database
I am having a springboot application where I am trying to connect to very old Oracle version 10.2.0.4.0 datasource.
My pom.xml has:
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
<version>21.1.0.0</version>
</dependency>
And my dockerfile has the similar above settings. While deploying code on the pod level, I get an exception that:
Failed to obtain JDBC Connection; nested exception is ja │ │ ORA-01882: timezone region not found
Oracle 10.2.0.4.0 has a Timezone 4. And my springboot application ojdbc driver is not compatible with the older oracle datasource.
I googled and found that I can use below dependency for this Oracle 10.2.0.4.0 version.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4.0</version>
</dependency>
ojdbc14 is the correct jar file to be pulled either by Maven which fails : no artifacts found.
When I tried to download ojdbc14.jar and tried manual settings in pom.xml
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ojdbc14.jar</systemPath>
</dependency>
Then I get an error while deployment at pod level which says that no suitable driver found.
Now I am stuck, on how to solve this problem.
Refer to the correct central maven repository for Oracle JDBC driver.
The other repository that you are using for 10.2.0.4 is not from Oracle and is very old and not supported.
I've created a new Spring Boot project. I'm trying to setup a DataSource to use MSSQL. However I seem to be getting the error "Unable to load class: com.microsoft.sqlserver.jdbc.SQLServerDriver"
I've placed the file jdbcsql4.jar in a folder in my project /lib/jdbcsq4.jar
In my pom.xml file I've added the following:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
<scope>system</scope>
<optional>true</optional>
<systemPath>${basedir}/lib/sqljdbc4.jar</systemPath>
</dependency>
I have an application.properties file, and I'm defining the database credentials like this:
secondary.datasource.url = jdbc:sqlserver://1.1.1.1:50109
secondary.datasource.username = sa
secondary.datasource.password = mypassword
secondary.datasource.driver-class-name = com.microsoft.sqlserver.jdbc.SQLServerDriver
Can anyone possibly indicate where I may be going wrong?
I managed to solve this issue by following the instructions in this link http://claude.betancourt.us/add-microsoft-sql-jdbc-driver-to-maven/
EDIT:
The original link above no longer exists, but here's a similar link.
http://biercoff.com/add-microsoft-sql-jdbc-driver-to-maven/
For the ppl who facing these issue.
Add dependency in POM.
Microsoft finally made the driver available on the Maven Central Repository.
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
you can check here.
Microsoft link
I am trying to run the liquibase update from Openshift machine that I have. It looks like
> java -jar ~/.m2/repository/org/liquibase/liquibase-core/3.1.1/liquibase-core-3.1.1.jar --driver=org.postgresql.Driver --classpath=wildfly/standalone/deployments/ROOT.war --changeLogFile=liquibase/changelog.xml --url="jdbc:$OPENSHIFT_POSTGRESQL_DB_URL/mydb" --username=$OPENSHIFT_POSTGRESQL_DB_USERNAME --password=OPENSHIFT_POSTGRESQL_DB_PASSWORD update
and I see the following error
Liquibase update Failed: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:postgresql://admin:29asDVjpFxYl6#127.8.201.2:5432/mydb with driver org.postgresql.Driver. Possibly the wrong driver for the given database URL
What is going wrong here?
I am using the following postgreSQL dependency
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
there were 2 issues that were fixed as following
a.) using postgres 9.2 driver
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1003-jdbc4</version>
</dependency>
b.) using the following url
--url="jdbc:postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT/mydb"
in java i want to use oracle XMLType.
I add
XMLType type = new XMLType(conn, "<shipTo></shipTo>");
but i always get
Caused by: java.lang.ClassNotFoundException: oracle.xml.parser.v2.XMLParseException
why? i am using xdb6.jar for oracle 11 database. For connection i am using JDBC.
Here's the excerpt from my POM for doing the same (in JBoss):
<!-- required for Oracle XML support -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>xmlparserv2</artifactId>
<version>11.2.0.1.0</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>xdb</artifactId>
<version>11.2.0.1.0</version>
</dependency>
i.e. you need the XDB and XMLParserv libraries.