about this package
This package contains sample applets and standalone applications that illustrate
various JDBC programming tasks with WebLogic jDriver for Microsoft SQL Server.
You should test your connection to SQL Server with the
utility before you attempt to use the examples.
SocketApplet simply opens a
socket to the port that the RDBMS is listening on. It should be the
first applet you attempt after installation. It
verifies that a SQL Server is listening on the hostname and port number
that you specify and that your applet viewer or web browser's
security manager permits opening such a socket.
ConnectionApplet establishes a JDBC connection with the RDBMS.
It should be the second applet you attempt after installation. Use it
to verify that JDBC driver manager can locate WebLogic jDriver for
Microsoft SQL Server and that your connection URL is correct.
SelectApplet establishes a JDBC connection and then performs a simple,
constant, query that does not rely on any tables in the RDBMS. It should
be the third applet you attempt after installation. Use it
to verify that you are able to connect to the RDBMS, perform
a query, and get results.
LargeTableTest creates a large table, reads back its
contents, then drops it from the database. This examples demonstrates
how to create a database object using a Statement, insert rows
individually using separate Statements, insert rows using
PreparedStatements, and retrieve rows using Statements or a stored
ProcedureTests demonstrates how to create a stored procedure,
call the procedure with input and output parameters, and remove the
stored procedure from the database.
When executing stored procedures with JDBC,
all results sets and update counts must be processed before
you can retrieve the values of output parameters. Executing a single
CallableStatement can cause multiple result sets and update counts.
All of these result sets and update counts must be processed
before you can retrieve the value of an output parameter.
demonstrates that WebLogic jDriver for Microsoft SQL Server is fully multi-threaded.
The test generates n connections spread among n threads.
If you plan to perform multi-threaded connectivity, use this test as an
This test also serves as a performance test for the JDBC driver, the middle
ware used (if any), and the SQL Server itself. If you are performance conscious,
compare other JDBC drivers to WebLogic jDriver for Microsoft SQL Server using this test.
The number of threads and connections used can be varied by changing the
constant values in the ThreadsTests.java
file. If the test fails to open all the connections you may have reached
the maximum number of concurrent clients allowed by your SQL Server (this
could be limited by your SQL Server license).
sqlBrowser is both a sample application and a utility. This
applet lets you type SQL statements in its top pane. It sends the SQL
sent to the server and displays the results in the bottom panel.
- complexproc illustrates how to retrieve rows and update
counts and/or output parameters from complex stored procedures that
may have multiples of any of these.
- exsql shows how to use Extended SQL.
- login demonstrates
three different ways to connect to a database, including setting
explicit properties for connection in the code, using command-line
arguments, and embedding properties for connection in a URL.
- records illustrates
inserting and updates records using a JDBC PreparedStatement.
- simpleselect shows how
to select data and database metadata, using a Statement, a ResultSet,
and a ResultSetMetaData.
- simplesql illustrates
how to drop and create tables and add and delete rows using
a Statement and standard SQL.
- storedprocs shows how to create and execute
stored procedures and get results.
how to use this package
To set up an environment for running these examples:
- Open a new shell for running these examples.
Set the CLASSPATH environment variable in that shell to include weblogic\mssqlserver4\classes.
For example (Windows NT):
$ set CLASSPATH=%CLASSPATH%;c:\weblogic\mssqlserver4\classes
Where weblogic is the directory where you installed WebLogic jDriver for Microsoft SQL Server.
- Change the database URL, login, and password connection parameters
to correspond to your Microsoft SQL Server configuration. (For
applets, the connection URL may be in the .html file or in
the .java source file.) If you need more help, check the
section on connecting to a database in the Developers Guide, Using WebLogic jDriver for Microsoft SQL Server.
- Compile these examples by executing the following command in your development shell:
$ javac -d c:\weblogic\mssqlserver4\classes *.java
Where c:\weblogic is the path to the directory where you
installed WebLogic jDriver for Microsoft SQL Server.
- To run a standalone application, execute the following command in
your development shell:
$ java examples.jdbc.mssqlserver4.className
- To run an applet, load the associated .html file into a browser.
Note that most browsers have security policies that restrict applets from
connecting to computers other than the one the applet was served from. That
means that you must install WebLogic jDriver for Microsoft SQL Server, the webserver,
and the database server all on one computer.
For testing, you can use appletviewer, which is included in the JDK.
appletviewer does not have the security restrictions.
WebLogic jDriver for Microsoft SQL Server for more information about applets and browser
there's more . . .
Read more about using this JDBC driver in the Developers Guide for
WebLogic jDriver for Microsoft SQL Server,
WebLogic jDriver for Microsoft SQL Server.