Win a copy of Terraform in Action this week in the Cloud forum!

Robert Brunner

Ranch Hand
+ Follow
since Jul 18, 2001
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Robert Brunner

Wow, your message totally screwed up my browser window. Very impressive.
Since I can't really see what you posted, I will only be able to give generalities. If you want to set a variable from a ResultSet object, you do is just as you would in any Java application with JDBC. For example, to set an integer value i
<%i = rs.getInt(1) ; %>

[This message has been edited by Robert Brunner (edited August 16, 2001).]
[This message has been edited by Robert Brunner (edited August 16, 2001).]

Originally posted by Guillaume Compagnon:
What is your opinion on the new release of JDBC API 3.0 ?

A good start point to know about JDBC 3.0 is:
for my part, the RETURN_GENERATED_KEYS function has been waited for a long time
The other features are aimed to improve performance with applications talking with DB. (connection & prepared statement pooling). That is SO important because the bottleneck is always (almost) with the communication with DB.

I am looking forward to the savepoints! Of course getting drivers that implement JDBC 3.0 will be an entirely different story. I know inet has Merlia, but other than that, its slim pickings.

Originally posted by Thomas Kyte:
Well, I would tend to disagree with the Object database comment as a "pointer" as you call it is really a step backwards somewhat in data integrity (we had that with network databases way back when). You lose the referential integrity rule the user wants. You can "point" to a user or a group but there is nothing stopping the system from deleting that user or group (leaving you with a dangling pointer that points to nothing). We can do that with REFs and UDTs as you point out but you have that nasty dangling ref issue.
In a pure relational world (as would be true in an OO world), the data model would involve some super type (suppose we call it "ENTITY"). The USER table would be a child table of ENTITY as would the GROUP table. Now the MESSAGE_TABLE has a foreign key to ENTITY (as the OO model would have a pointer to an ENTITY instance but the pointer might be the USER or GROUP as ENTITY is probably an abstract class)..
So, one method to solve this is to have tables such as:
create table entity( id int primary key, data varchar2(10) );
create table users
( id primary key references entity, other_data varchar2(10) );
create table groups
( id primary key references entity, other_data varchar2(10) );
create table messages
( msg_id int primary key, who_from references entity );

Hi Thomas,
Its all fine to disagree, but be sure your facts are straight. OODBMS often provide referential integrity as a user option. You can propogate behaviors along links however you wish, including locking options, copying behavior (shallow vs. deep), delete behaviors, etc. Thus your criticism is completely unfounded.
The reason OODBMS did not succeed had little to do with the quality of the products, and a lot to do with the strength of the RDBMS vendors and the lack of an OODB standards.

Originally posted by Jamie Robertson:
If you are using statements you can do the following:
String query = "select * from emp";
rs = stmt.executeQuery(query);
Unfortunately with PreparedStatements you can only print out the individual parts of it:
String query = select * from emp where id = ?";
PreparedStatement ps = con.prepareStatement(query);
Hope this helped a little bit. If you are looking for a method like ResultSet.getQueryString(); I think you're out of luck.


Actually, there is a tool called a JDBC spy driver, which actually shows the SQL that is being used by the database (which may be different than what is in your java code. Merant provides a version (not sure who actually wrote it). Basically, the spy driver does the normal stuff, but also logs what it is sending.
Again, very useful for actual debugging, especially with complex joins or stored procedures.

Originally posted by karim qazi:
Can anyone explain to me how to use the ConnectionPoolDataSource vs. DataSource.
I know how to get a connection using the DataSource interface how can you get a ConnectionPoolDataSource instead?

Easy, rather than creating an object that implements the DataSource interface, you implement an object that implements the ConnectionPoolDataSource.
You then get a PooledConnection object via getPooledConnection(), and then you get a connection from this PooledConnection via getConnection(). Everything else is the same. So essentially, you only have one changed step, and one additional step to take advantage of connection pooling.
ConnectionPoolDataSource ds = new ConnectionPoolDataSource() ;
// Set datasource properties
PooledConnection pcon = ds.getPooledConnection() ;
Connection con = pcon.getConnection() ;
Could you post more information about the problem you are having?

Originally posted by Robin Richardson:
I've checked all those sites already. They all seem to be geared toward Windows only, of course since I'm not very familiar with Solaris I may be missing something, and I need to know exactly how to add the driver to the Solaris CLASSPATH (/user/....) so that it will work on this system. I have not been able to find the correct settings.
Thank you

Type 4 rivers are pure Java, they will work on any JVM (in theory at least). Try to download an evaluation version and test it out. I now people who have done JDBC on an AS400.
As far as CLASSPATH, it works just like on Windows. Exact format depends on your shell. Try set CLASSPATH for sh, and setenv CLASSPATH for csh. Driver documentation should help.

Originally posted by Raghav Subramanian:
I am trying to insert multiple values into multiple tables at a single instance.I have a HTML form and Servelt that connects me to the MSAccess database . i have 4 different tables in the database.and i want to enter the values in the form to these tables in a single submit button click. i tried doing
Statement st = conn.createStatement();
st.addBatch("insert into table 1");
st.addBatch("insert into table 2");
st.addBatch("insert into table 3");
st.addBatch("insert into table 4");
int [] count = st.executeBatch();
but i am getting a error all the time i do it this way , is this any other way to carry out this type of operation.

Raghav, What error are you getting? You could do this without a batch statement. Disable autocommit, do all the inserts, and then do an explicit commit. You may need to do this if your driver does not support batch statements (which I do not think the JDBC-ODBC bridge does).

Originally posted by justin deming:
I want to check if the resultset from my jdbc/oracle query contains anything so I say:
if( == false) {
tell the user there were no results using jsp1
else {
while( {
print the results using jsp2
The problem occurs when the resultSet is not empty and else is executed. Since has been called in the if statement the results start printing at the second record. I tried calling resultSet.previous() before the while loop but it is a forward only resultSet.
Can anyone think of a better way to check this condition or how the make the resultSet traverseable in two directions?

Hi Justin,
First, the answer to your second question is that in JDBC 2, ResultSets can be bi-directional, so you can start at the bottom and work your way up or vica-versa. You can also setFetchDirection to tell the database you want to do this implicitly. Of course all of this assumes your driver and database support these sorts of things.
Now, on to your first question. There are several options you have. First, you can do the normal thing
while( {
// do your thing
status = true ;
// Tell user no data
You also could do something similar to what you had written (and was sort-of indicated by an earlier post.
do {
//process the results
// tell user no data
Hope this helps.
20 years ago
Try doing it in JSP. You can set up a loop to itereate over the result set and print out the html as you want.
20 years ago

Originally posted by Sophia Oscario:
I try to use Pool Manager 2.0 to handle database connection to MySQL from JSP.
But it returns an execption :
Exception Report:
javax.servlet.ServletException: javax/sql/ConnectionEventListener
at org.apache.jasper.runtime.PageContextImpl.handlePageException(
at org.apache.jsp.JDBCtest_jsp._jspService(
at org.apache.jasper.runtime.HttpJspBase.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(
at org.apache.jasper.servlet.JspServlet.serviceJspFile(
at org.apache.jasper.servlet.JspServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardPipeline.invokeNext(
at org.apache.catalina.core.StandardPipeline.invoke(
at org.apache.catalina.core.ContainerBase.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardPipeline.invokeNext(
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
at org.apache.catalina.core.StandardPipeline.invokeNext(
at org.apache.catalina.core.StandardPipeline.invoke(
at org.apache.catalina.core.ContainerBase.invoke(
at org.apache.catalina.core.StandardContext.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.core.StandardPipeline.invokeNext(
at org.apache.catalina.valves.AccessLogValve.invoke(
at org.apache.catalina.core.StandardPipeline.invokeNext(
at org.apache.catalina.core.StandardPipeline.invoke(
at org.apache.catalina.core.ContainerBase.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.core.StandardPipeline.invokeNext(
at org.apache.catalina.core.StandardPipeline.invoke(
at org.apache.catalina.core.ContainerBase.invoke(
at org.apache.catalina.connector.http.HttpProcessor.process(

Here's My code :
<title>JDBC - MySQL</title>
<%@ page language="java" import="java.sql.*,com.codestudio.util.*" %>

<% SQLManager myManager = SQLManager.getInstance(); Connection myConn = myManager.requestConnection(); Statement st = myConn.createStatement(); ResultSet rs = st.executeQuery("select * from employee"); if (rs != null) { while ( { String eid = rs.getString("empid"); String name = rs.getString("lastname") + ", " + rs.getString("firstname"); String extention = rs.getString("extention"); %> <% } } st.close(); myManager.returnConnection(myConn); %>
ID Name Extention
<%=eid %> <%=name %> <%=extention %>

Please anybody can tell me what's wrong ...

I can't see you code. Try to resubmit just your code.

Originally posted by JiaPei Jen:
Is the bundled with the Oracle8i? Where should I place the in my directory?

Yes, it is included, look under your Oracle Home directory in the JDBC/lib subdirectory. Once you find it, you will need to put it in the classpath of any JVM that you want to be able to access it.

Originally posted by Farooq Ali:
Another question..
Can MS Ole-Db be used somehow instead of the standard ODBC/DSN technique?? to connect to a java program??

Hi Farooq,
I have never heard/seen it done, although maybe some of the type 4 JDBC drivers do that directly. Java programs expect to talk to a database using the JDBC API (even JDO is layered on top of JDBC for SQL data stores). The only way ODBC is used is with the JDBC-ODBC bridge.

Originally posted by Robin Richardson:
Hello, I'm working on a project that requires that the program I'm working on runs on a Solaris 7 server. I have written the program on Windows 2000 due to problems getting a driver for AS400 (DB2, or so I'm told) to work on the Solaris 7 box. Can anyone tell me if there is a driver available? If so, please direct me to that site, and the appropriate download/installation instructions
Thank you
Robin Richardson

Robin, did you try IBM's site? Also, check out drivers from Merant, and HITSW.,2722,,00.html

Originally posted by Chetan,Mehta:
Can someone please tell me what are the differences between avaliable types?
How do we identify for a given scenario which is the best suitable driver for use?
I understand that we have type1, type2 , type3 and type4 driver avaliable by Specification.
I needed help understanding scenario where particular driver can be the best fit.

Hi Chetan,
This is actually easy, although it may not seem so. Type 1 is the JDBC-ODBC bridge driver. You only use it for ODBC connections, like ACCESS or Excel. It is not for distributed Apps.
Type 2 is basically non-existant, don't even worry about them (they are part Java, part native code, thus DB specific code has to be installed on each client).
Type 3 drivers communicate in a database independant protocol with a special middleware server, which then communicates directly with your database. This type is nice if you want to be able to easily move your app between databases (but this is less important with introduction of datasources).
Type 4 is a high performance all Java driver which communicates direcxtly with the database of choice.
I would recommend you get a Type 4 if at all possible.