codice:
Connection conn=null;
try{
//Uso i driver MySql
Class.forName("com.mysql.jdbc.Driver");
//Mi collego in remoto al Db con User e //Pass impostati nel DB sul server.
//Questo esempio penso valga per un solo
//utente, non so come impostarlo per più
//non ho mai provato :( al posto di //Localhost metti l'url del Server
// e al posto di test il nome del tuo DB
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","User","Pass");
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("SELECT * from Giocatori");
while(rs.next()){
System.out.print(rs.getString("Codice"));
System.out.print(rs.getString("Ruolo"));
System.out.print(rs.getString("Nome"));
System.out.print(rs.getString("Squadra")+"\n");
}
rs.close();
}catch(IOException r){
out.println("IOException ");
//out.println(r.getMEssage());
}
catch(SQLException sqle){
out.println("SQL Exception");
//out.println(sqle.getMessage());
}
catch(ClassNotFoundException cnfe){
//out.println("CLassNotFoundException ");
out.println(cnfe.getMessage());
}
catch(Exception ex){
out.println("Exception");
}
finally{
try{
if(conn!=null) conn.close();
}catch(Exception f){}
}
Questo che ho postato e' un codice moooooooooolto semplice e scarno
Spero sia ciò che cerchi