请教线程问题(各位大人请进)
package com.nb.adv.carinfo;
import
java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import
java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import com.zl.base.core.db.Executer;
import com.zl.base.exception.DbException;
public class DGSServer {
public static void main(String[] args) throws
ParseException, DbException
{
try{
String CarID,Longitude,Latitude,Time= " ",Flag;
System.out.println( "Start server... ");
Calendar now =Calendar.getInstance();
// Integer year=new Integer(now.YEAR);
// Integer month =new Integer(now.MONTH);
// Integer day =new Integer(now.DATE);
Date datetime1=now.getTime();
//String year1 = year.toString().substring(2,4);
SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMdd HH:mm:ss ");
String datetime = sdf.format(datetime1);
String message1= datetime.substring(2,4)+datetime.substring(4,8)+ "| "+datetime.substring(9,11)+datetime.substring(12,14);
System.out.println(datetime);
DatagramSocket s=new DatagramSocket(10000);
byte[] data=new byte[100];
DatagramPacket dgp=new DatagramPacket(data,data.length);
while(true){
s.receive(dgp);
String str1=new String(data).trim();
//String str2= new String(str1.getBytes(), "gb2312 ");
System.out.println(new String(data).trim());
//拆分字符串
String[] splitstring= str1.split( "\\| ");
//给各个变量赋值
CarID = splitstring[1];
Longitude =splitstring[2];
Latitude =splitstring[3];
Flag =splitstring[4];
//时间字符串拼凑
Time = "20 "+splitstring[5].substring(0,2)+ "- "+splitstring[5].substring(2,4)+ "- "+splitstring[5].substring(4,6)+ " "+splitstring[6].substring(0,2)+ ": "+splitstring[6].substring(2,4)+ ": "+ "00 ";
System.out.println(Time);
// 插入数据库数据
String Sql = "insert into CarInformation(CarId,Longitude,Latitude,Time,Flag) values ";