Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package test2;
- //queries the books table in database wbluhm on multivac
- import java.sql.*;
- import java.applet.*;
- import java.awt.*;
- public class testdatabse extends Applet {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- public static class Global {
- public static String A = null;
- public static int H = 0;
- }
- public void init(String A) {
- try {
- Class.forName("org.gjt.mm.mysql.Driver").newInstance();
- }
- catch (Exception E) {
- System.err.println("Unable to load driver");
- E.printStackTrace();
- }
- try {
- Connection C = DriverManager.getConnection(
- "jdbc:mysql://localhost/marc","user","user123");
- Statement Stmt = C.createStatement();
- ResultSet RS = Stmt.executeQuery
- ("SELECT * From bezetting ");
- while(RS.next()){
- Global.A = Integer.toString(RS.getInt("dow"));
- Global.H = Global.H + 20;
- }
- C.close();
- RS.close();
- Stmt.close();
- }
- catch (SQLException E) {
- System.out.println("SQLException: " + E.getMessage());
- System.out.println("SQLState: " + E.getSQLState());
- System.out.println("VendorError: " + E.getErrorCode());
- }
- }
- public void stop(){/**/}
- public void paint(Graphics g){
- //method to draw text on screen
- // String first, then x and y coordinate.
- g.drawString(Global.A,20,Global.H);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement