Home| Progetto| Web| Faq| Acronimi | ||||
Argomenti Documenti pubblicabili:1120
Scripts:1282 Documenti non pubblicabili:162 Categorie tematiche:68 .Net |_C# |_Visual basic.net |_Asp.net Active Server Pages C++ Cascade Style Sheet JavaScript Mysql Php Xml Java |_Java 2 Micro Edition |_Java server pages |_Java Servlet Oracle |_PLSQL PostgreSQL Unix
Java...
Info:
Java conceived as an interpreted language
Oracle...
Script:
Cercare le colonne in uno schema
Unix...
Tip:
How remove a file named -r
PLSQL...
Script:
Organizzazione del codice e gestione degli errori
Java...
Tip:
Classpath per compilazione
Shell scripting...
Script:
Formatting text as bold withing shell script
A User Agent, like a web browser, uses HTTP to request a HTML document
Php Funzione mail()
In programming the danger of exploring the small details of coding is that you get obsessed with every line of code you write, thereby greatly reducing productivity.
In general, is not worth obsessing over code. On the other hand you should code with deliberation and intent. Steven Feurstein Oracle Magazine July /August 2004 A User Agent, like a web browser, uses HTTP to request a HTML document
|
Java
Home >Java > Connessione ad un database ed estrazione dei dati
/******************************************************************** * SEMPLICE APPLICAZIONE: CONNESSIONE A DATABASE(Mysql) via jdbc, Estrazione dei dati * Marco Magnani 2003 Freeware * Java Tutorial JDBC Example adapted to MySQL * MM MySQL Driver Version -> http://www.mysql.com/ scaricare mysql-connector-java-2.0.14.zip * Note: installare il driver per Mysql com.mysql.jdbc oppure scaricare il Driver mm.jdbc e * modificare il codice * Per eseguire il programma sono necessarie le strutture mysql * database: mydatabase * tabella: members (popolata) * cfr. la sezione mysql per le isruzioni necessarie * Può essere necessario settare username e password *******************************************************************/ import java.sql.*; public class mysqlQuery { public static void main(String args[]) { // ---- configure this for your site String username = null; String password = null; // Sintassi: jdbc:TYPE:machine:port/Nome_database String url = "jdbc:mysql://localhost/mydatabase"; // Stringa sql String queryString = "SELECT NAME, CREDITS FROM MEMBERS"; // caricamento del Driver (Codice specifico del Produttore) try { Class.forName("com.mysql.jdbc.Driver"); } catch(java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } try { Connection con; Statement stmt; // Connessione al database con = DriverManager.getConnection(url, username, password); System.out.println ("Ok, la connessione e' stata attivata."); System.out.println ("Proviamo ad estrarre i dati con la seguente query: " + queryString); // Creazione dell'oggetto Statement stmt = con.createStatement(); // esecuzione della query and e creazione del resultset ResultSet rs = stmt.executeQuery(queryString); // svolgimento del resultset while (rs.next()) { String s = rs.getString("NAME"); float n = rs.getFloat("CREDITS"); System.out.println(s + " " + n); } // Chiusura delle risorse stmt.close(); con.close(); } // Gestione degli errori catch(SQLException e) { System.err.println("==> SQLException: "); while (e != null) { System.out.println("Message: " + e.getMessage ()); System.out.println("SQLState: " + e.getSQLState ()); System.out.println("ErrorCode: " + e.getErrorCode ()); e = e.getNextException(); System.out.println(""); } } } } Warning: include(ads/text468x15.html): failed to open stream: No such file or directory in D:\inetpub\webs\fishscriptcom\documents\view_document.php on line 131 Warning: include(): Failed opening 'ads/text468x15.html' for inclusion (include_path='.;C:\php\pear') in D:\inetpub\webs\fishscriptcom\documents\view_document.php on line 131 Tutorial ![]() ![]() ![]() ![]() ![]() ![]() ![]() Script ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Comandi ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Cerca
Java...
Info:
Java conceived as an interpreted language
Anger is creative, depression is useless.
Dyson, Freeman J. Anger is creative, depression is useless.
Dyson, Freeman J.
Java...
Info:
Java conceived as an interpreted language
Java...
Definizioni:
Ereditarietà delle classi
Oracle...
Definizioni:
Transazione
Shell scripting...
Script:
Hide user input on screen
fishScript.Com is accessible by Mobile access technology
as mobile phones, Palm and Pocket PC .
Nicoleta e Marco Magnani tutorial, examples, courses, esempi, corsi, esercizi, appunti vari Dottoressa Nicoleta Dragu Formatrice Docente Insegnante Mediatrice Culturale Dott. Marco Magnani Universita La Sapienza Roma Master Computer Science Hunter College New York , Data Base Administrator DBA oracle System architect |