1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| package training1;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class jdbc {
private static Connection connect;
private String url = "jdbc:sqlite:C:\\Users\\tosiba\\eclipse-workspace\\training1\\src\\training1\\BDD.db";
public jdbc(){
try {
try {
Class.forName("org.sqlite.JDBC");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
connect = DriverManager.getConnection(url);
initialise();
} catch (SQLException e) {
e.printStackTrace();
}
}
private void initialise() {
// TODO Auto-generated method stub
}
public static Connection getInstance() throws SQLException{
if(connect == null){
new jdbc();
// System.out.println("INSTANCIATION DE LA CONNEXION SQL ! ");
}
else {
System.out.println("CONNEXION SQL EXISTANTE ! ");
}
return connect;
}
} |