mysql & JDBC - results returned to a GUI window (app)
This code below can be used to return data from a mysql server running on the Z or any mysql server on your network and display it from in an GUI app window.
What you will need -
mysql server - download and install onto a system on your computer
mm.mysql-2.0.4-bin.jar - jdbc driver (required)
Downloads -
coming soon..
How to run the app -
coming soon
Output -
The app shown in the screen below is called PersonalProfileApp. But the code below is MysqlQuery. I am going to create another screenprint later.
In the meanwhile make sure you run evm MysqlQuery.

Code - (it's very crude but works)
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.applet.Applet;
import java.sql.*;
public class MysqlQuery extends Frame implements
ActionListener {
Label panelLabel = new Label("Panel");
Button button2 = new Button("Exit");
Panel panel = new Panel();
Panel panel2 = new Panel();
Label label = new Label("Button:");
int count = 0;
TextArea textfield = new TextArea(4,15);
public void start(String args) {
setLayout(new FlowLayout(FlowLayout.CENTER));
panel2.setLayout(new FlowLayout(FlowLayout.CENTER,2,2));
panel2.add(textfield);
add("North", panel2);
panel.setLayout(new FlowLayout(FlowLayout.CENTER,2,2));
panel.add(button2);
add("North", panel);
button2.addActionListener(this);
textfield.setText(args);
validate();
}
//-----------------------------------------------------------
// ActionListener Interface
//-----------------------------------------------------------
public void actionPerformed(ActionEvent event) {
String str = event.getActionCommand();
if (str == "Exit")
System.exit(0);
}
public static void main(String argv[])throws Exception {
MysqlQuery testApp = new MysqlQuery();
//--------------
String xx="";
Class.forName("org.gjt.mm.mysql.Driver");
// on a PC you might also use another driver
// Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// which provides access to the JDBC-ODBC bridge
// quite handy for local PC prototyping...
// establish connection to database on server
//Connection con = DriverManager.getConnection(
// "jdbc:allbase://your3k/musicdbe.grp.acct", "user.acct",
"upass,apass"
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/mysql?user=root&password=");
// or with JdbcOdbc bridge "jdbc:odbc:YourDSN", "NoUser",
"NoPass"
//);
// create an SQL statement to be executed
Statement st = con.createStatement();
// send a query to the database server
ResultSet rs = st.executeQuery("select User from user");
// retrieve and display the resulting entries
while (rs.next()) {
System.out.println(rs.getString("User"));
//xx=(rs.getString("User"));
xx = xx + rs.getString("User")+ "\n";
}
// close resources aquired
rs.close();
st.close();
// release the database connection
con.close();
//---------------
testApp.start(xx);
testApp.setSize(220, 200);
testApp.validate();
testApp.show();
}
}