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
| /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author USER
*/
import java.sql.*;
public class connexion {
public static void main(String [] args){
Connection con = null;
Statement stm= null;
ResultSet rs=null;
String que="";
String name="ok";
String age="ok";
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://localhost:1433;databaseName=test;user=SQLEpress;password=xxxxxx;";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);
}
catch(Exception ex){
System.out.println(ex.toString());
}
try
{stm = con.createStatement();
que ="insert into prof([nom],[prenom],)values('"+name+"','"+age+"')";
}
catch(Exception exp){System.out.println(exp.toString());
}
}
} |
Partager