|
|
Ligne 25 : |
Ligne 25 : |
| | | |
| '''Comparing SQLfast and Java/JDBC'''<br> | | '''Comparing SQLfast and Java/JDBC'''<br> |
− | The SQLfast code (here just a simple SQL query) is executed at level 0 (Learning SQL), when database ORDERS.db has been opened. Error exceptions are coped with automaticallly. | + | The SQLfast code (here just a simple SQL query) is executed at level 0 (Learning SQL), when database ORDERS.db has been opened. Error exceptions are coped with automatically. |
| {| | | {| |
| |<div style="width: 260px;height:300px;padding-left:5px;padding-top:1px;background-color:#E5E5E5;"> | | |<div style="width: 260px;height:300px;padding-left:5px;padding-top:1px;background-color:#E5E5E5;"> |
Version du 21 décembre 2015 à 12:15
Contact
Address/Adresse
- PReCISE / LIBD
- Faculté d'informatique
- Rue Grandgagnage, 21
- B-5000 Namur - Belgium
Accès/Access: Français English
- Jean-Luc Hainaut (e-mail: jean-luc.hainaut AT unamur.be)
- Vincent Englebert (e-mail: vincent.englebert AT unamur.be)
- Anthony Cleve (e-mail: anthony.cleve AT unamur.be)
Please ignore the following section
Comparing SQLfast and Java/JDBC
The SQLfast code (here just a simple SQL query) is executed at level 0 (Learning SQL), when database ORDERS.db has been opened. Error exceptions are coped with automatically.
select NCLI,NOM from CLIENT;
|
import java.net.URL;
import java.io.*;
import ...;
import java.sql.*;
import java.util.*;
String url = "jdbc:interbase://server1/CLICOM.gdb";
String user ="myLogin";
String pw="myPassword";
Connexion conn = null;
Statement stmt = null;
ResultSet res = null;
String selectQ = "select NCLI,NOM from CLIENT";
String CiD;
String Cnom;
try {
Class.forName("interbase.interclient.Driver");
conn = DriverManager.getConnection(url,user,pw);
}
catch (Exception e) {
System.err.println( e.getClass().getName()
+ ": " + e.getMessage() );
System.exit(0);
}
try {
stmt = conn.createStatement ();
res = stmt.executeQuery (selectQ);
System.out.println("NCLI, NOM");
while (res.next()) {
CiD = res.getString("NCLI");
Cnom = res.getString("NOM");
System.out.println(CiD + ", " + Cnom);
}
res.close();
stmt.close();
conn.close();
}
catch (Exception e) {
System.err.println( e.getClass().getName()
+ ": " + e.getMessage() );
}
|
<Retour à la page d'accueil / Back>