connection cannot be made with derby client jdbc driver - java

im using Eclipse Helios Java EE IDE for Web Developers,Version: 1.3.0. connection with derby embeded jdbc driver is workin fine but i cannot make connection with derby client jdbc driver... what should i do to make it work,please help me...

connection with derby embeded jdbc driver is workin fine but i cannot make connection with derby client jdbc driver
Providing details (what you did, what didn't work, etc) is generally useful to get good answers. Here are some things to check though:
make sure derbyclient.jar is on the classpath
make sure you are using org.apache.derby.jdbc.ClientDriver as driver class
make sure the URL follows the following format jdbc:derby://<host>:<port>/<database>
make sure the network server has been started(!)

Related

Use SSL for JDBC Pool Connection to Oracle Database from Java Application Server

I'm currently trying to implement a SSL connection from the jdbc-pool of our java application server to our Oracle database.
We're using Payara (based on glassfish) as our application server. On there I created a JDBC-connection pool that offers a connection to the database. The goal ist to encrypt this connection.
The used ojdbc driver version is 11-21.1.0.0.
Sadly I only found guides on how to encrypt payara JDBC-pool connections to postgres or mysql databases, not to oracle ones.
The only thing I found was that apparently the pool has to talk to port 2484 on the database (link).
Does anyone have any experience with how to solve this problem?
What parameters, aside from port, do I have to set in the advanced properties of the jdbc-pool?
Any help would be highly appreciated!
Can you check the JDBC Developer's guide for security information?
Check out www.oracle.com/jdbc for other resources.

Eclipse Database Connection Driver Definition

I am using Eclipse Oxygen with Glassfish 5. I am Trying to connect to Derby. After selecting Derby from connection profile types I did next and my driver was empty (Specify a Driver and Connection Details) So I clicked on new driver definition
In properties there is no localhost or Port. And the Connection URL does not has it either
Connection Test is successful. I did changed the connection URL so it has port and Host but then Connection test failed. I'm learning Java EE and in tutorial it has host and port while i don't so i'm confused. Any Help ?
Host and port are used with the client driver, not with the embedded driver.
If your deployment approach is to deploy the Derby Network Server and then connect to it with one or more client applications that you are writing, then go back to the first step of your question and pick the Derby Client Driver, from derbyclient.jar.
By the way, I hope you are not really using Derby versions 10.1, 10.2, etc. Those are extremely old versions. Try to use Derby version 10.14 if you can, it's the most recent. You can download the latest Derby release from here: https://db.apache.org/derby/derby_downloads.html After you have downloaded Derby, and unzipped it into a folder on your laptop, load the latest 'derbyclient.jar' and 'derby.jar' into Eclipse so that you can work with the up-to-date JDBC drivers.
For some basic information about the difference between the client-server and embedded configurations of Derby, look here: https://db.apache.org/derby/docs/10.14/getstart/cgsquck70629.html
Many more details about the client-server configuration are explained here: https://db.apache.org/derby/docs/10.14/adminguide/index.html
While if you really do want to use the embedded Derby configuration, but were just confused about why you don't need a host and port for that configuration, try looking here: https://db.apache.org/derby/docs/10.14/devguide/cdevdvlp39409.html

Connect my Java application to SQL Server 2012 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a SQL Server 2012 database in the network of my company.
I can access to this database to observe the tables etc... with SQL Server Management Studio giving the following :
Server type : Database Engine
Server name : xxx-yyy-zzz.eu.company.corp, number_of_port
Authentication : Windows Authentication
Username and password
I also know the name of the database and nothing more.
I would like to connect a new Java program I am writing with Eclipse to this SQL Server database. But I have never connected or even used a SQL Server before so I have no idea how to do it. I understood reading some other posts that I need a driver, but I don't understand where I need to install this driver, which driver and what I need to do to extract data from the database in my Java program.
Could you please tell me more about it ? Thank you :)
I suggest you start here with this Microsoft documentation, Microsoft JDBC Driver for SQL Server.
Looks like you can download the actual driver from Microsoft JDBC Driver 6.0 for SQL Server.
What you need to do may vary depending on the operating system you are using however the above driver looks to be pretty inclusive for Linux, Windows and also works with Azure, Microsoft's cloud offering.
The Programming Guide for JDBC SQL Driver has a number of links explaining what you will need to do and Building the Connection URL describes the actual connect string.
This stack overflow post has a sample program. Java program to connect to Sql Server and running the sample query From Eclipse.
You may also find How to connect to Microsoft SQL Server database using Eclipse to be helpful.
Just remember, you need Eclipse IDE for Java EE developers to access
the database. It contains tools for database development e.g. database
explorer. The Eclipse IDE for Java Developers doesn't contain those
tool by default. FYI, I am using Eclipse Java EE IDE for Web
Developers, Version: Kepler Service Release 2.
Some time back I had problems with Microsoft JDBC Driver and used open source JTDS. I do not remember exact problems, but JTDS worked just fine for me.
So, code to connect to database may look like:
//Not required anymore - just for demonstration. Driver class must be in class path
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection dbCon = DriverManager
.getConnection("jdbc:jtds:sqlserver://{db_host}:[db_port]/{Database Name};domain={user Windows domain};user={user id};password={user password}");
PreparedStatement stmt = dbCon.prepareStatement("SELECT GETDATE()");
ResultSet resSet = stmt.executeQuery();
while (resSet.next()) {
System.out.println(resSet.getString(1));
}
System.out.println("Done");
dbCon.close();
Maven dependency for JTDS driver:
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
BTW: Maybe there is a newer version available...

Connect to a SQL Anywhere 5.0 DB from java

I need to connect to a Billing system which is backed by a SQL Anywhere 5.0 DB and I am pretty much drawing a blank when I try to find a jodbc driver for this.
I was successful in doing this with an upgraded version(SQL Anywhere 11) by using the iAnywhere jodbc drivers that I found in the DB installation folder.
DriverManager.registerDriver((Driver) Class.forName("ianywhere.ml.jdbcodbc.jdbc3.IDriver").newInstance());
con = DriverManager.getConnection(String.format("jdbc:ianywhere:dsn=%s;uid=%s;pwd=%s;", dbDsn, dbUser, dbPassword));
But, the 5.0 version does not have any JDBC-ODBC drivers.
Also, I need to connect via the odbc way as the DSN is created and managed by the Billing software.
Any help with this would be greatly appreciated.
If I understand you correctly, you need to connect from your unnamed Java app to the target SQL Anywhere 5.0 DB, through the ODBC DSN maintained by the Billing software. That means you need a JDBC Driver for ODBC Data Sources, such as the one from my employer. The free two-week trial should be enough for your to figure out whether this will do the job for you.

How do I make a HSQLDB 2 client program?

I have a small HSQLDB program to test bits of SQL. I am getting this error:
A pre-version 2.0 client attempted to connect. We rejected them.
Yet the only JDBC driver I have is the HSQLDB v2.3 in the most recent download:
hsqldb/lib/hsqldb.jar
I'm using this string to load the JDBC driver:
Class.forName("org.hsqldb.jdbcDriver");
And the connection string is:
connectionStr = "jdbc:hsqldb:hsql://localhost/tmp_db";
user=sa, password=
Default values. My HSQLDB server seems to have started OK with a database as follows:
server.dbname.0=**tmp_db**
server.database.0=file:r:/.data/hsqldb/**tmp_db/tmp**
[Server#372f7a8d]: Database [index=2, id=2, db=file:r:/.data/hsqldb/**tmp_db/tmp**, alias=tmp_db] opened sucessfully in 26 ms.
I'm using Netbeans and when I connect via the Services tab, the database seems to be opening OK. Wouldn't Netbeans be using the same driver? Can I check that?
The big question is how do we specify the version 2 client connection, driver or parameters? Must I get a different JAR for the correct driver?
One last thing. The test program works fine if I use a file based connection, such as:
jdbc:hsqldb:db_file
Frustratingly too, the server connection string seemed to be working earlier today. At least I could drop/create tables while I was making changes.
You must use the same jars (or at least recent, compatible versions) on the client and server.
The error shows you are using the 2.x version jar on the server but a 1.8 jar on the client. Check NetBeans to see if some extension you have loaded has the old driver. You can use the correct jar in your NetBeans project by adding it as a library.
If the error is not from NetBeans, check your application's classpath and make sure you have the latest jar in it.

Categories