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

PLEASE HELP!!!

Status
Not open for further replies.

ceaton

MIS
Apr 26, 1999
27
US
I'm in need of some help rather fast, project due!!<br>
<br>
I have this project due and the boss is<br>
breathing down our necks, anyway I need to know how to call some<br>
classes. I have this button on an applet from which I need to trigger<br>
the following class. <br>
<br>
void va_MouseClicked(java.awt.event.MouseEvent event)<br>
{<br>
I need to pass a string or label to my class.<br>
}<br>
<br>
<br>
This is my query class, now I need to make several of these, I'm just not sure how to put all three of my class to work together. I think I'm really missing something here, just not sure what.<br>
<br>
<br>
import java.awt.*;<br>
import java.io.*;<br>
import java.sql.*;<br>
import java.net.URL;<br>
<br>
public class BRR extends Object {<br>
JVRConn conn; <br>
<br>
public BRR(JVRConn _conn) {<br>
<br>
conn = _conn;<br>
<br>
String specLiab; <br>
PreparedStatement prepstmt;<br>
<br>
// the labelspecliab is what I need to retrieve from my button,<br>
// I can either pass this as a label or string.<br>
<br>
specLiab = ces.labelspecliab.getText().toString();<br>
<br>
try {<br>
boolean found = false;<br>
prepstmt = JVRConn.theConn.dbConn.prepareStatement<br>
(&quot;SELECT BRR FROM LIAB WHERE TEXT = ?&quot;);<br>
prepstmt.setString(1, specLiab); <br>
<br>
<br>
ResultSet rs;<br>
rs = prepstmt.executeQuery();<br>
<br>
found = rs.next();<br>
if (found)<br>
System.out.println(rs.getString(1));<br>
else<br>
System.out.println(&quot;Not here&quot; + specLiab + &quot;);<br>
prepstmt.close();<br>
}<br>
catch(Exception e ) {<br>
e.printStackTrace();<br>
}<br>
}<br>
<br>
}<br>
<br>
This is my class to make the connection to my db. I know this is correct. I can't just put them together.<br>
<br>
import java.net.URL;<br>
import java.sql.*;<br>
<br>
class JVRConn {<br>
static myConnection theConn;<br>
<br>
public static void main (String args[]) {<br>
theConn = new myConnection();<br>
theConn.Connect2Db(&quot;JVR&quot;, &quot; &quot;, &quot; &quot;);<br>
} <br>
}<br>
<br>
class myConnection {<br>
Connection dbConn = null;<br>
void Connect2Db(String db, String user, String passw) {<br>
try {<br>
// using the driver<br>
Driver d = <br>
(Driver)Class.forName<br>
(&quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;).newInstance();<br>
// URL corresponding to the ODBC DSN<br>
String URL = &quot;jdbc:eek:dbc:&quot; + db;<br>
// DB logon<br>
dbConn =<br>
DriverManager.getConnection(URL, user, passw); <br>
}<br>
catch (Exception e) {<br>
e.printStackTrace();<br>
}<br>
}<br>
<br>
void Disconnect2Db() {<br>
try { <br>
dbConn.close(); <br>
}<br>
catch (Exception e) {<br>
e.printStackTrace();<br>
}<br>
}<br>
} <p> Courtney<br><a href=mailto: ceaton@lrp.com> ceaton@lrp.com</a><br><a href= > </a><br>
 
<A HREF=" TARGET="_new"><br>
this forum appears to be more active that tek-tips....for future reference. i'm going to try it for a few days to see if i like it. hth:) <p>bobbie "in chicago"<br><a href=mailto:thibault@hotbot.com>thibault@hotbot.com</a><br><a href= </a><br>today's weather: clowdy 63 fahrenheit:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top