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
| /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mysqlconnection;
import java.sql.*;
/**
*
* @author Mankou
*/
public class Mysqlconnection {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception{
// TODO code application logic here
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/xmlprojet","root","");
PreparedStatement statement = con.prepareStatement("select * from coordonnees");
ResultSet result = statement.executeQuery();
while(result.next()){
System.out.println(result.getString(1)+" "+result.getString(2)+" "+result.getString(3)+" "+result.getString(4)+" "+result.getString(5));
}
}
} |
Partager