Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ResultSet Question 1

Status
Not open for further replies.

Alastor

MIS
Aug 27, 1998
36
US
I was playing around and I passed a ResultSet to a String variable and when I printed the string I got this:<br>
<br>
sun.jdbc.odbc.JdbcOdbcResultSet@b80f70e7<br>
<br>
Is this telling me the location in memory of the ResultSet? Can I do anything with this information?
 
p.s.<br>
<br>
Is there a way to pass a ResultSet to an applet from a servlet?
 
Hi!<br>
<br>
I think, that you are on the wrong way. I can pass (perhaps) the ResultSet to the applet (if you wrap it into a serializable object, and make a TCP connection, and write/read ObjectStream-s), but when you use a RS (next, etc.) it want to connect to the database via jdbc (i think), and it will do several errors, because the applet do not load the jdbc drives, etc.<br>
Try to send all rows (fields) individually trough on TCP connection or make RMI object, or generate the total html page to the client with servlet.<br>
Good luck. Bye, Otto.<br>

 
I didn't figure that was a way to pass the ResultSet, I just did it to see what would happen. I was wondering if the hex number indicated the location in memory where the ResultSet was stored.<br>
<br>
What I want to do is display the ResultSet in a Swing table which is why I'm trying to send it to an applet. Is there a way to display a Swing table in a servlet? From what I've seen you can only send html output from a servlet.<br>
<br>
I'm trying to pass the ResultSet to the applet as an object through a socket connection but I keep getting a 'Connection Refused' error message. I'm relatively new to java and this is my first time setting up a socket connection. If you have any hints or tips or reference sources I would really appreciate the info. Thanks.
 
Hi!<br>
<br>
Sorry, but I did not understand you clearly. I should gladly help you, but tell me more your project.<br>
Do you write a client-server style application to the internet/intranet or only a to a local machine?<br>
I think that you do not need (perhaps) servlet. You can use jdbc connection from an applet. Or you can run a simle java application and it will serve data via socket connection to the client applet. If you need, I send you a very (very) simle example.<br>
Bye, Otto.
 
Thanks for your help. What I am trying to do is query and display data from an Access database to the internet. I have an html form setup with a POST method to a servlet. The servlet then queries the database based on the form information and creates a ResultSet. Everything works up to this point. What I want to do from here is pass the data from the ResultSet to an applet so that I can display the data in a Swing table. I'm trying to setup a socket connection that will pass the ResultSet object to the applet but I keep getting a 'connection refused' error message.
 
Hi!<br>
<br>
I think there is no simply way to pass the original resultset to an applet.<br>
I advice you two sollutions:<br>
<br>
1. Write a Server application, which is listening a port, and wait for the<br>
Client(s) to connect. Invent an own protocol (Do the query, get result lines,<br>
close the connection, etc.). Run this on the server's JVM. Write a java applet<br>
client, that will connect the server (IP, Port) and realize the protocol, and<br>
show the result(s).<br>
Source: DBServer.java<br>
<br>
2. Write a Servlet (you have done it), and generate a standard HTML file<br>
(for example a TABLE), or an own data stream from the result (ResultSet).<br>
Write a client applet, that will realize the POST method, pass the variables,<br>
and then will read the servlet answer, and show it the required form (split<br>
fields, records from the HTML or datastream).<br>
Source: DBQueryServlet.java, DBQuery.html, DataFromSrvlToApplet.java,<br>
DataFromSrvlToApplet.html<br>
<br>
The sources was splitted my former try-outs, I hope them will help you.<br>
Ah, you can find the sources at my place :), <br>
Bye, Otto.<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top