Technical FAQ: General questions about jdbcKona
FAQ Index
Using the jdbcKona drivers on IRIX
I am having trouble using the new Application Binary Interface (ABI)
for shared libraries with my jdbcKona driver. What's wrong?
Currently, the native drivers do not work with the new ABI because of
an incompatibility with the database client library. As a work-around,
you can use the older ABI by adding the -o32 option when starting Java.
How can I tell if the database is unavailable?
Is there a way to know whether a database has gone down, and come up
again?
You can do this from within your
program. A database that is down has no way of notifying anyone of its
status (because it is down). Therefore, your program logic should test
for the availability of a resource (such as a database) before
accessing that resource, and then you can determine how your
program should respond to that information. For examples, you could notify the user
that there is a problem and exit gracefully. You might also wish to
have your program notify the appropriate person that there is a
problem with the database.) In the case of java.sql.Connection, an SQLException is thrown that you can
catch and deal with as suggested above.
If you are using connection pools, you have additional options for
dealing with this situation.
Generally, database availability
is a system-administration problem that probably requires
human intervention.
Errors running t3dbping
I am testing my Oracle database connections under UNIX. I am able to
run SQL*PLUS and can successfully ping the database using utils.dbping. However, when I use the
multitier
utils.t3dbping
utility, I receive an ORA-12154 error message. What's going on?
First, make sure that your ORACLE_HOME environment
variable is correctly set to point to your Oracle installation. This
variable must be set in the environment where the WebLogic
server is running.
-
In the C-shell issue the following command:
$ setenv ORACLE_HOME path
where path is the path to your Oracle installation.
In the Bourne shell, issue the following commands:
$ ORACLE_HOME=path
$ export ORACLE_HOME
where path is the path
to your Oracle installation.
When you ping your database using the two-tier
utils.dbping utility, the JDBC
driver loads the database client library
and establishes the connection to the database. When you use the
multitier utils.t3dbping
utility, the WebLogic Server loads a two-tier driver and uses it to
establish a database connection. In both cases, the same method is
used to connect to the database. SQL*PLUS works because it doesn't
require ORACLE_HOME to find the client libraries.
If you are still experiencing problems, try this:
- Open a command shell.
- Run the two-tier
version of utils.dbping in
this shell.
- Start WebLogic in this shell from the command line:
$ java -ms32m -mx32m weblogic.server
- Open a second command shell.
- Run the utils.t3dbping
in the second shell against the server running in the first command
shell.
If this procedure doesn't work, please send the output from these
commands to WebLogic technical
support.
What's a "native" JDBC driver? What's the
difference between a Java and a "Java-only" JDBC driver?
Why are some JDBC drivers billed as "Java-only?"
What's a "native" JDBC driver?
Some JDBC
drivers written in Java work by calling database vendors'
platform-specific database client libraries, such as Oracle's OCI or
Sybase's DB-Library. These libraries are written in C, not Java. A
JDBC driver that uses these native libraries uses a Java mechanism
called Java Native Interface (JNI) that makes it possible for a
Java program to access platform-specific native code. There are
some restrictions on how and where native methods can be used. For
example, Java JDBC drivers are not appropriate for use in
Netscape applets
because of restrictions on the use of native methods.
WebLogic offers Type 2 "native" JDBC drivers that work only
with specific, individual client libraries, for Oracle, Sybase, and
Microsoft SQL Server. Because the vendors' client libraries are not
written in Java, the WebLogic
native drivers use a very thin C layer to make calls into
the client library. This WebLogic native layer is supplied as
a .dll for Windows or an .so or .sl for UNIX.
When you use a WebLogic native driver, you need the
WebLogic Java classes as well as the appropriate native library
for the vendor library for your database.
WebLogic also provides a Type 3 pure-Java JDBC driver, WebLogic JDBC.
A pure-Java JDBC driver does all of its work exclusively in Java,
without any use of native methods, which is how WebLogic JDBC
works. WebLogic JDBC can be used within the WebLogic framework without
accessing any vendor-specific database libraries.
In addition, WebLogic supplies Type 4 pure-Java two-tier
drivers for Informix and Microsoft SQL Server. These can
be downloaded separately from the WebLogic website.
What do I need to connect to a database with JDBC and Java?
You need the following pieces:
- A database (Oracle, Sybase, Microsoft SQL Server, for example)
- A JDBC driver, such as a WebLogic jdbcKona driver
(jdbcKona/Oracle, jdbcKona/Sybase, or jdbcKona/MSSQLServer)
- For a Type 2 JDBC driver, the 32-bit vendor client
libraries for the database (.dll for Windows NT or .so or .sl for UNIX)
- If you want to access a database using JDBC from an applet running
in a browser, the WebLogic multitier JDBC driver, WebLogic JDBC
- Java
Developers Kit
How do I connect to a DBMS with
jdbcKona?
Can you give me some tips on how to connect to a DBMS with jdbcKona?
You do this in a Java program by setting properties with a Properties
object, and then passing the Properties object and the URL of the
driver to the DriverManager to create a connection.
This is documented in detail for each of the WebLogic jdbcKona JDBC
drivers in the following Developers Guides:
If you use the utils.dbping
utility to check your database connection, you get
output that includes sample code for connecting to the database.
Why can't my class find the WebLogic driver?
I've written a test class to log into an Oracle database, insert and
delete some records, and close. When I try to run my class file, it
fails to find the WebLogic driver.
Here is a troubleshooting checklist:
- Did you use the product's
application or the command-line dbping utility to test your
connection to the database?
- Are your DBMS environment variables set in the shell from
which you are running the application, or -- if you are using an applet
-- the shell from which you are running the WebLogic Server?
- Did you install the appropriate 32-bit vendor library
(required by a two-tier jdbcKona driver)?
- Are you loading the WebLogic driver properly in your code?
If you are using a two-tier
jdbcKona driver (like jdbcKona/Sybase), you can check examples of how
to do this in the Native
jdbcKona driver overview and implementation guide. If you are using
WebLogic JDBC,
then you must load two JDBC drivers, one for the connection
between the WebLogic Server and the database, and one for the
connection between the WebLogic JDBC Client and the WebLogic
Server. Please verify that you are doing this properly by checking
Step 4 in the Developers Guide
for WebLogic JDBC.
- Did you specify the datasource properly? Do this with a URL
or with a java.util.Properties object. There is also information on
this in the Native jdbcKona
driver overview and implementation guide and the Developers Guide for
WebLogic JDBC. For more detailed information on using URLs,
check the administrator guide Using
URLs with WebLogic products.
- If you are using WebLogic JDBC, WebLogic's multitier
JDBC driver, you also need to specify a WebLogic Server with
a URL. Check your syntax against the example code in the WebLogic JDBC developers
guide.
UnsatisfiedLinkError while testing my two-tier connection . . .
I'm working on Windows 95 with Sybase SQL Anywhere 5.5 and Symantec
Cafe Lite. My CLASSPATH
is set correctly, but I get an UnsatisfiedLinkError when I test the
connection using java
utils.dbping as you suggest. Here is the stack trace:
C:\WINDOWS>java utils.dbping SYBASE DBA SQL sademo
Unable to load dll 'weblogicsyb26.dll' (errcode = 485)
java.lang.UnsatisfiedLinkError: no weblogicsyb26 in shared library path
at java.lang.Runtime.loadLibrary(Runtime.java:274)
at java.lang.System.loadLibrary(System.java:274)
at weblogic.jdbc.dblib.Driver.connect(Driver.java:66)
at java.sql.DriverManager.getConnection(DriverManager.java:95)
at utils.dbping.main(dbping.java:47)
What's the problem?
jdbcKona/Sybase doesn't work with SQL Anywhere, unless you are running
the OpenServer TDS bridge. The .dll load is failing because it cannot
find the Sybase client libraries it expects.
Locating the shared library for
HP-UX green threads
When I install the .sl for HP-UX 10.20 in ~java/lib/PA_RISC/green_threads/ the JDK doesn't seem
to be able find it. I thought the JDK automatically appended the
green_threads library.
The JDK
does not append the green-threads library to the SHLIB_PATH. When
operating on HP-UX, the JDK will not find the shared library
(.sl) unless the library is in the path defined by SHLIB_PATH. To
check the current value of SHLIB_PATH, at the command line type:
$ echo $SHLIB_PATH
Use the set or setenv command (depending on your
shell) to append the WebLogic shared library to the path defined by
the symbol SHLIB_PATH. To have the shared library be recognized in a
location that is not part of your SHLIB_PATH, you will need to contact
your system administrator.
Unable to connect to my database! UnknownHost Exception . . .
We think we're just one step away from testing our connectivity to our
Oracle database. We have been able to test connectivity from other
applications and through SQL*PLUS, but we're still unable to connect
from our Java application with your jdbcKona driver. We're getting
the error: "Failed to find host: java.net.UnknownHostException." The
host machine is up and running at the IP address 127.0.0.1. What's the
problem?
We do not recognize 127.0.0.1 as a valid IP
address, since it is a special case that is the
equivalent of "localhost". To use our products, you must have a
permanent IP address assigned by your Internet Service Provider (ISP).
How can I find out how many rows
are returned after I execute a query?
After I execute a query (using the Statement.execute() methods), how can I find out how
many rows are returned in the ResultSet, if no rows are returned, and
if any error occurred while executing the query?
You do not know how many rows are in a ResultSet until you have
fetched them all, that is, until you have called the ResultSet.next() method for each
record returned by the query. If an error occurs, an Exception will be
thrown.
Can I interleave two statements on a single connection?
I want to interleave two statements over the same connection,
executing first one, then the other. I'm executing a JDBC
PreparedStatement repeatedly, and I want to avoid the overhead of
opening and closing Statements repeatedly. How can I do this?
If you are using an Oracle database, you can interleave multiple
Statements on the same Connection.
For Sybase and Microsoft SQL Server, the fundamental rule for multiple
statement execution on the same Connection is this: After you
execute a Statement, you must read all the results from that
Statement, and then cancel or close the Statement. If you try to issue
another execute on that Statement or on any other Statement on the
same Connection, you will get a DB-Library error.
You can open another Connection to perform other operations on the
database, but the SQL Server may cause your new Connection to wait if
it accesses a table or a page that has been locked by a query on the
first Connection. In some cases this will also lead to a deadlock on
the SQL Server, which will eventually cause a SQLException to be
returned to one of the Connections.
For more detailed information on interleaving Sybase queries, see the
topic "Interleaving operations on a connection" in the Developers guide for
jdbcKona/Sybase and jdbcKona/MSSQLServer.
Why do I get the error "No
weblogicoci32 in shared path" using the jdbcKona driver?
When I try to use the jdbcKona driver to connect to my database, I get
a "No weblogicoci32/weblogicoci32 in shared path" error. What am I
doing wrong?
In order to use the jdbcKona
drivers, you need to have the native class libraries installed on your
client machine and located where your program can find them. When your
Java program goes to connect to your database, it needs to be able to
access these libraries. The Oracle, Sybase, and MSSQLServer versions
of these libraries are shipped with the WebLogic distribution. See
these installation guides for more information on installing the Oracle, Sybase and MS SQL Server versions of
the jdbcKona libraries.
Why am I getting an access
violation in Netscape?
I'm using a native jdbcKona driver, the Netscape Enterprise
server/2.0b4, and the JDK 1.0.2 compiler. When I try to execute a
jdbcKona query, I get an HTTPD.EXE access violation. No error message
is recorded in my Netscape Enterprise server log. I've verified that
the connection to my Sybase DBMS is working with utils.dbping, as you
instructed in the installation instructions. What's the problem?
You cannot use the native jdbcKona drivers with the server-side Java
in the Enterprise server because Netscape does not allow third-party
Java with native methods. You can use WebLogic JDBC
or one of the Type 4 jdbcKona drivers, since they are Java-only.
