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
| package connectionbdd;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
/**
* <p>Titre : </p>
* <p>Description : </p>
* <p>Copyright : Copyright (c) 2006</p>
* <p>Société : </p>
* @author non attribuable
* @version 1.0
*/
import com.mysql.jdbc.Driver;
public class MAIN {
String url;
String user;
String password;
Connection con;
Statement stmt;
public MAIN() {
url = "jdbc:mysql://localhost/database";
user = "root";
password = "";
try {
Class.forName("com.mysql.jdbc.Driver");
} catch(ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,user,password);
//stmt = con.createStatement();
} catch (SQLException e) {
System.out.println("Echec connection");
}
}
public static void main(String[] args)
{MAIN mm=new MAIN();}
}
///=====================================================// |
Partager