Re: JDBC connection to mysql problem
On Sep 22, 7:53 am, "John B. Matthews" <nos...@nospam.invalid> wrote:
In article
<dd4df2ee-ce08-45b9-ba63-a1f00e51d...@f26g2000vbm.googlegroups.com>,
bruce <bruc...@bellsouth.net> wrote:
I debug, single step, over this statement and get the error
"Connection = >"Connection" is not a known variable in the current
context.<"
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:
3306/mydb", "myuser", "mypw");
"import java.sql.Connection;" is defined, with all my other import
statements..
I'm also getting that error for "Statement" and "ResultSet"
See also <http://forums.sun.com/thread.jspa?threadID=5271290>
[Please do not quote signatures.]
Maybe you were asking for a more complete copy of my code. So, I'm
posting the routine hear:
private void btnSaveActionPerformed(java.awt.event.ActionEvent evt)
{
String str;
String reelNo = txtReelNo.getText().trim();
System.out.println(reelNo);
try {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(Census1930.class.getName()).log(Level.SEVERE, null,
ex);
}
Connection con = DriverManager.getConnection("jdbc:mysql://
localhost:3306/censusrecords", "censusrecords", "password");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT lastname FROM
data1930");
rs.next();
str = rs.getString("lastname");
} catch (SQLException ex) {
Logger.getLogger(Census1930.class.getName()).log(Level.SEVERE, null,
ex);
}
}