N
Neil Bisby
Hi
I wondered if you could throw some light on a problem I am having.
I have written some code to access a mysql database (shown below). It
runs fine on the Forte development environment with the mysql.jar file
alongside the applet, however, when I copy the files to a web server,
it does not work. I am not sure waht is wrong, but everything I have
read, indicates that it should work.
If this is the wrong group for this question, and I should be posting
it elsewhere, please let me know and I will use that group instead.
Enjoy
Neil
Connection con = null;
// Load class
try
{
// Package "com.mysql.jdbc.Driver"
Class.forName("com.mysql.jdbc.Driver").newInstance();
label1.setText( "SQL Driver loaded sucessfully");
}
catch (java.lang.Exception e)
{
String sqlError = new String("SQL Class.forName Failed - "
+ e.getMessage());
label1.setText(sqlError);
}
try
{
con = DriverManager.getConnection(url, "root", "");
//con = DriverManager.getConnection(url, "root", "");
label2.setText("Got Connection");
// Create a statement
stmt = con.createStatement();
// Issue a query
rs = stmt.executeQuery("select * from org");
while (rs.next())
{
sResult += rs.getString("orgname") + ">>> ";
}
// Put the result in a label
label2.setText(sResult);
}
catch (java.sql.SQLException e)
{
label2.setText(e.getMessage());
}
if (con != null)
{
try
{
con.close();
label3.setText("Connection Opend and Closed");
}
catch (Exception e)
{
label3.setText(e.getMessage());
}
}
I wondered if you could throw some light on a problem I am having.
I have written some code to access a mysql database (shown below). It
runs fine on the Forte development environment with the mysql.jar file
alongside the applet, however, when I copy the files to a web server,
it does not work. I am not sure waht is wrong, but everything I have
read, indicates that it should work.
If this is the wrong group for this question, and I should be posting
it elsewhere, please let me know and I will use that group instead.
Enjoy
Neil
Connection con = null;
// Load class
try
{
// Package "com.mysql.jdbc.Driver"
Class.forName("com.mysql.jdbc.Driver").newInstance();
label1.setText( "SQL Driver loaded sucessfully");
}
catch (java.lang.Exception e)
{
String sqlError = new String("SQL Class.forName Failed - "
+ e.getMessage());
label1.setText(sqlError);
}
try
{
con = DriverManager.getConnection(url, "root", "");
//con = DriverManager.getConnection(url, "root", "");
label2.setText("Got Connection");
// Create a statement
stmt = con.createStatement();
// Issue a query
rs = stmt.executeQuery("select * from org");
while (rs.next())
{
sResult += rs.getString("orgname") + ">>> ";
}
// Put the result in a label
label2.setText(sResult);
}
catch (java.sql.SQLException e)
{
label2.setText(e.getMessage());
}
if (con != null)
{
try
{
con.close();
label3.setText("Connection Opend and Closed");
}
catch (Exception e)
{
label3.setText(e.getMessage());
}
}