PHP expert |
|
Home written:
import java.sql.*;
class dataobject {
public static void main(String[] args) {
Connection con;
Statement stmt;
ResultSet rs;
String id, naam;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:JOUW_DATABANK", "GEBRUIKERSNAAM", "WACHTWOORD");
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM test");
System.out.println("Gegevens van test db");
System.out.println("---------------------------------------");
while (rs.next()) {
id = rs.getString("id");
naam = rs.getString("naam");
System.out.println("ID: "+ id);
System.out.println("Naam: "+ naam);
System.out.println("========================");
}
rs.close();
stmt.close();
con.close();
}
catch (ClassNotFoundException cnfe) {
System.out.println(cnfe);
}
catch (SQLException sqle) {
System.out.println(sqle);
}
}
}
import java.sql.*; class dataobject { public static void main (String [] args ) { Connection con; Statement stmt; ResultSet rs; String id, naam; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:JOUW_DATABANK", "GEBRUIKERSNAAM", "WACHTWOORD"); stmt = con.createStatement(); rs = stmt.executeQuery("SELECT * FROM test"); System.out .println ("Gegevens van test db"); System.out .println ("---------------------------------------"); id = rs.getString("id"); naam = rs.getString("naam"); System.out .println ("ID: "+ id ); System.out .println ("Naam: "+ naam ); System.out .println ("========================"); } rs.close(); stmt.close(); con.close(); } catch (ClassNotFoundException cnfe) { } catch (SQLException sqle) { } } }
Je moet natuurlijk je databank wel toevoegen aan je obdc list. Daarom moet je eerst dit hier downloaden, installeren en dan naar je odbc panel gaan (de rest wijst zich vanzelf uit): http://dev.mysq.../3.51.html
Have fun! |