Connection with Sybase - java

I am new to Sybase ,I'm developing a web application with sybase and jboss, my app connect with the Sybase database. I have put the jconn4.jar in same directory with war file in deployments directory . My config in standalone.xml like this
<connection-url>jdbc:jtds:sybase://<myserver>:<myport>/<mydb></connection-url>
<driver-class>com.sybase.jdbc4.jdbc.SybDriver</driver-class>
<!--<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class> -->
<driver>jconn4.jar</driver>
and when i use com.sybase.jdbc4.jdbc.SybDriver got the error message
javax.resource.ResourceException: Wrong driver class [class com.sybase.jdbc4.jdbc.SybDriver] for this connection URL [jdbc:jtds:sybase://<myhost>:<myport>/<mydb>
...
when i use net.sourceforge.jtds.jdbc.Driver i got the message
java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver from [Module "deployment.jconn4.jar:main" from Service Module Loader]
I don't know what driver-class suitable for driver class jconn4.jar

You are using the driver url of the open source jTDS driver, but you are trying to use the Sybase driver. Use the right JDBC url for the Sybase driver: Check the documentation included with the Sybase driver for details (I can't be more specific because the Sybase documentation is usually hard to find online without access to the support portal). Or switch to jTDS, in which case you need to deploy it as a module to JBoss and reference the right driver module in the config.

Related

What is the correct procedure for adding SQL Server JDBC to GlassFish 3.1.2

I am setting up a test GlassFish Server to learn NetBeans, Java, GlassFish web application development. I was able to do a basic deployment successfully and am moving on to databases.
I am trying to set up a MS SQL Server connection pool in the GlassFish admin. After configuring the datasource as javax.sql.Datasource and setting the properties, it fails to successfully ping the connection.
When I try to ping the connection, I get this error
Ping Connection Pool failed for SQLDB. Class name is wrong or classpath is not set for :
com.microsoft.sqlserver.jdbc.SQLServerDataSource
It looks like the .jar file isn't being loaded. I have placed the sqljdbc4.jar in the glassfish\modules folder.
What is the correct process for setting up a JDBC connection pool for SQL Server?
In case you are using JRE 7 : use JDBC41
in case you are using JRE 8 : use JDBC42
Unzip the exe from the following link : https://www.microsoft.com/en-us/download/confirmation.aspx?id=54671
Paste the jar in the lib folder of glassfish .
Once done define property under connection pool as URL and pass full qualified connection name as : jdbc:sqlserver://localhost\MSSQLSERVER:1433;databasename=AdventureWorks2016;integratedSecurity=true

icCube driver not found: org.postgresql.Driver

I'm trying to evaluate icCube and I have a problem when I try to connect a PostgreSQL datasource. When I test the connection I get an error message about PostgreSQL driver missing:
Failed to establish the connection due to the error: JDBC driver class 'org.postgresql.Driver' not found in the classpath
I've checked the lib directory of icCube and it has postgresql-9.4.1207.jre7.jar bundled in the release, is there anything I'm missing?
To fix this, I had to add the PostgreSQL JDBC driver to bin/icCube.sh in the JDBC section:
CLASSPATH="$CLASSPATH:$ICCUBE/lib/postgresql-9.4.1207.jre7.jar"

Which is the sybase driver(version) to be used in Weblogic 12c ? Where should I add the downloaded driver?

I am migrating my application from Weblogic 9 to 12c.
The connection pool - cvSybasepool created for my application is working fine on Web logic 9.
I had used com.sybase.jdbc.SybDriver to connect to Sybase database on Weblogic 9.
After replicating the connection pool(cvSybasepool) on Weblogic 12c, I get the following error:
<Jun 21, 2016 4:40:25 AM EDT> <Error> <Deployer> <BEA-149205> <Failed to initialize the application "cvSybasepool" due to error weblogic.application.ModuleException: weblogic.com
mon.resourcepool.ResourceSystemException: Cannot load driver class com.sybase.jdbc.SybDriver for datasource 'cvSybasepool'.
weblogic.application.ModuleException: weblogic.common.resourcepool.ResourceSystemException: Cannot load driver class com.sybase.jdbc.SybDriver for datasource 'cvSybasepool'.
at weblogic.jdbc.module.JDBCModule.prepare(JDBCModule.java:350)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:175)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:170)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
Truncated. see log file for complete stacktrace
Caused By: weblogic.common.resourcepool.ResourceSystemException: Cannot load driver class com.sybase.jdbc.SybDriver for datasource 'cvSybasepool'.
at weblogic.jdbc.common.internal.JDBCUtil.parseException(JDBCUtil.java:322)
at weblogic.jdbc.common.internal.ConnectionEnvFactory.loadDriver(ConnectionEnvFactory.java:82)
at weblogic.jdbc.common.internal.ConnectionEnvFactory.<init>(ConnectionEnvFactory.java:141)
at weblogic.jdbc.common.internal.ConnectionPool.initPooledResourceFactory(ConnectionPool.java:1110)
at weblogic.common.resourcepool.ResourcePoolImpl.start(ResourcePoolImpl.java:226)
Truncated. see log file for complete stacktrace
>
I suspect the Sybase JDBC driver jar is missing on Web logic 12c.
Also, When the Sybase driver provided by Web logic server is used, I get the following error
FILogger.log(232) - java.sql.SQLException: [FMWGEN][Sybase JDBC Driver][Sybase]A USE DATABASE statement is not allowed in a procedure or trigger. at weblogic.jdbc.sybasebase.ddcn.b(Unknown Source) at weblogic.jdbc.sybasebase.ddcn.a(Unknown Source) at weblogic.jdbc.sybasebase.ddcm.b(Unknown Source) at weblogic.jdbc.sybasebase.ddcm.a(Unknown Source)
Which driver needs to be used to connect to Sybase DB on Weblogic
12c? Jconn2.jar/Jconn3.jar?
Which jar needs to be added to Weblogic server?
Where do I need to add the jar and what configuration has be done?
I finally resolved the issue.
I could not use the sybase driver(weblogic.jdbc.sybase.SybaseDriver) bundled with weblogic as it was not complaint with my SQL code
Below are steps I followed.
Downloaded & copied JDBC driver JAR - jConnect.jar to
${WL_HOME}/server/lib/
Updated the setDomainEnv.cmd script in my domain's bin directory,
and prepended the JAR file to the PRE_CLASSPATH environment
variable(If the newly added JDBC driver JAR is required in other
domains, then edit the commEnv.cmd/sh script in WL_HOME/common/bin
and prepend your JAR file to the WEBLOGIC_CLASSPATH environment
variable.)
Restarted the server.
Update or re-create your datasource to use the sybase driver available with weblogic server 12c (weblogic.jdbc.sybase.SybaseDriver)

Openshift Postgresql connection error:

Edited: I checked the log file, and the URL message is:
Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'postgresql://adminxxxxxxx:xxxxxxxxx#10.1o.1o.10:5432'
I get the following error with postgres on openshift (9.x)
java.sql.SQLException: No suitable driver
java.sql.DriverManager.getDriver(DriverManager.java:278)
My URL is ${OPENSHIFT_POSTGRESQL_DB_URL}
This exact build works on my local host (different URL, of course), and I can see the openshift jar in the correct place in the war file
Any ideas?
Turns out the URL in the environment variable on Openshift does not work.
See here:
http://mikeski.net/blog/index.php?/archives/17-Postgres-and-JBoss-on-openshift.html

Unable to connect SQL database in Netbeans

I am trying to create a simple web application in J2EE.
I am getting the following error:
exception:
javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get
connection,
DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc/qweDS"
root cause:
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid:
"java.sql.SQLException: No suitable driver found for jdbc/qweDS"
added thee resource, created the connection pool, checked the connection.. enabled the driver.. checked web.xml file and glassfish-resources.xml
Any idea what am I doing wrong. or where to set the driver.
You need to download a suitable JDBC driver depending on your database, then right-click on the project on Netbeans and click Add Library. After that choose the JDBC.jar file you downloaded and try again.
You have notincluded driver jar file. According to your database you have to include driver jar file like in Mysql you have to include mysql-connector-java-(version).jar
You can download from internet

Categories