I'm in need of some help rather fast, project due!!<br>
<br>
I am so new to java and I have this project due and the boss is breathing down our necks, anyway I need to know how to call some classes. I have this button on an applet from which I need to trigger 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>
("SELECT BRR FROM LIAB WHERE TEXT = ?"<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("Not here" + specLiab + "<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("JVR", " ", " "<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>
("sun.jdbc.odbc.JdbcOdbcDriver".newInstance();<br>
// URL corresponding to the ODBC DSN<br>
String URL = "jdbcdbc:" + 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>
<br>
I am so new to java and I have this project due and the boss is breathing down our necks, anyway I need to know how to call some classes. I have this button on an applet from which I need to trigger 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>
("SELECT BRR FROM LIAB WHERE TEXT = ?"<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("Not here" + specLiab + "<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("JVR", " ", " "<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>
("sun.jdbc.odbc.JdbcOdbcDriver".newInstance();<br>
// URL corresponding to the ODBC DSN<br>
String URL = "jdbcdbc:" + 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>