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
|
import java.sql.*;
import java.io.*;
import java.util.*;
import java.applet.*;
public class essai_bdd extends Applet
{
public void init()
{
try
{
System.out.println("Connection au driver JDBC");
Class.forName("com.mysql.jdbc.Driver").newInstance();
System.out.println("Driver com.mysql.jdbc.Driver charge");
try
{
System.out.println("Connection a la base de données");
String url="jdbc:mysql://localhost/coursenlignealgo";
Connection conn = DriverManager.getConnection(url,"root","");
System.out.println("Base de données connectée");
}
catch (SQLException ex)
{
System.out.println(ex.getMessage());
System.out.println(ex.getSQLState());
System.out.println(ex.getErrorCode());
}
}
catch (Exception ex)
{
System.out.println("Echec de chargement du driver");
}
}
} |
Partager