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 56 57 58 59 60 61 62 63 64 65 66 67
|
public void InserSql()
{
Connection con=null;
PreparedStatement ps=null;
try
{
String cmd;
cmd=null;temp=null;
cmd="insert into trame(id,type,temps,etat,coord,vitesse,cap,date,declin,chek) values(null,'";
cmd=cmd+type+"','";
temp=heure[0]+":"+heure[1]+":"+heure[2];
H=temp;
cmd=cmd+temp+"','";
cmd=cmd+etat+"',";
temp=temp.valueOf(latitude[0]);
temp=temp+"°"+latitude[1];
temp=temp+"."+latitude[2];
temp=temp+directionlat;
La=temp;
String coord=new String();
coord="Geomfromtext('Point(21 21)')";
cmd=cmd+coord+",";
temp=temp.valueOf(longitude[0]);
temp=temp+"°"+longitude[1];
temp=temp+"."+longitude[2];
temp=temp+directionlong;
Lo=temp;
cmd=cmd+vitesse+",'";
cmd=cmd+cap+"','";
System.out.println("6");
temp="";
for(int i=0;i<3;i++)
temp=temp+date[i]+"-";
cmd=cmd+temp.substring(0, temp.length()-1)+"','";
D=temp.substring(0, temp.length()-1);
temp=dec+directiondec;
cmd=cmd+temp+"','";
cmd=cmd+checksum+"')";
System.out.println("cmd = "+cmd);
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/NMEA","root","boumacmilan");
ps = con.prepareStatement(cmd);
System.out.println("tst1");
ps.executeUpdate();
System.out.println("tst2");
JOptionPane.showMessageDialog(null, "c'est fait!!","Display Message", JOptionPane.INFORMATION_MESSAGE);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, "une erreur c'est produite les details sont: "+e,"Display Message", JOptionPane.ERROR_MESSAGE);
}
} |
Partager