La classe Statement - Esempio | |
// Crea la tabella 'table' nel database, tramite // la connessione 'conn' void createTable (Connection conn, String table) { try { // Crea uno 'statement' sulla connessione Statement dbst = conn.createStatement(); // Usa 'executeUpdate' perche' la query non ritorna dati dbst.executeUpdate("create table " + table + " (num integer, txt text);"); dbst.close ();// Occorre sempre chiudere quando abbiamo finito } catch (SQLException e) { System.out.println ("Non riesco a creare la tabella "+ table); System.out.println (e); } } |
© Ing. Stefano Salvi - All rights reserved