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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem displaying a class...

Status
Not open for further replies.
Oct 22, 2001
215
US
Hi,
I am a newbee in this and got my first Java /Aceess program. It is working fine that is, it is connecting to an Ms Access db and runs an sql and display the result.
----------
.
java.sql.ResultSet rs = st.executeQuery("select * from contact");
java.sql.ResultSetMetaData md = rs.getMetaData();
while(rs.next()) {
System.out.print("\nTUPLE: | ");
for(int i=1; i<= md.getColumnCount(); i++) {
System.out.print(rs.getString(i) + &quot; | &quot;);
}
}
----------
OK So far so good. (It displays the result in command prompt: java localdemo)...
Now I am trying to call this class from web page but it is saying class not fonud..!
All I am tring to do:
----
<p>
<applet CODE=&quot;localdemo.class&quot; CODEBASE=&quot;localdemo&quot; WIDTH=125 HEIGHT=30></applet></p>

----
Or I should try some thing else? TIA
 
Not quite sure I understand the problem completely. It would probably help out a lot more if you included all of your source here. Looks to me like you are having some classpath issues, but then again without seeing your code its pretty hard to tell for sure.

-gc &quot;I don't look busy because I did it right the first time.&quot;
 
Hi,
My code works fine... I just want to display this into the browser. Any way, here is my code:
localdemo.java:
import java.sql.*;

public class localdemo {
public static void main(String[] args) {
try {
Class.forName(&quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;).newInstance();

// Test with MS Access database (rjdemo ODBC data source)
String url = &quot;jdbc:eek:dbc:rjdemo&quot;;

java.sql.Connection c = DriverManager.getConnection(url,
&quot;admin&quot;, &quot;rjdemo&quot;);

java.sql.Statement st = c.createStatement();
java.sql.ResultSet rs = st.executeQuery(&quot;select * from contact&quot;);

java.sql.ResultSetMetaData md = rs.getMetaData();
while(rs.next()) {
System.out.print(&quot;\nTUPLE: | &quot;);
for(int i=1; i<= md.getColumnCount(); i++) {
System.out.print(rs.getString(i) + &quot; | &quot;);
}
}

rs.close();

} catch(Exception e) {
e.printStackTrace();
}
}
};


 
Well, The main problem that I see is that while this may work great on the command line, its not going to work in an Applet.

If you want to be able to display this code using an applet, you must first extend JApplet or Applet. After that, you are going to need to get rid of the main method, and add your results to a panel in some way (ie, by using some kind of component).

I could give you a small sample to llok at if you are interested, but I would probably just go to Sun's site and look at a tutorial for Applets.

-gc &quot;I don't look busy because I did it right the first time.&quot;
 
Thanks... that is what I thought. Do you recommend any site? Yes can you please post an example? By the way, Is ODBC faster or use using RMI will be faster? --TIA
 
Take a look at this site for a demo:
As for ODBC, and RMI. You are talking about 2 different things. I would use a RMI server using JDBC. This wil make your architecture a little more distributed. If you are interested in this you would need to write a RMI server that did the database calls for you, and then write a bean to access the server from your applet. You can of course just use JDBC from your applet itself, but that is usually not considered very good architeture.

-gc &quot;I don't look busy because I did it right the first time.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top