import java.io.BufferedReader;
import java.io.FileReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class operateDateBase {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
Connection ct = null;
PreparedStatement ps = null;
int a = 0;
try {
String ur1 = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:/周报客户端/周报客户端/personal.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
ct = DriverManager.getConnection(ur1);
BufferedReader br = new BufferedReader(new FileReader(
"C:\\Users\\aaa\\Desktop\\日行簿.txt"));
String line = br.readLine();
while (line != null) {
line = line.trim();
String[] tt = line.split("\\.");
for (int i = 0; i < tt.length; i++) {
System.out.println(tt[i]);
}
ps = ct
.prepareStatement("insert into T_WeekReport values(?,?,'ZHSFPT',3,0,0,0,0,0,0,0,0,0,?,'','0',?,?,1,0,'','')");
ps.setString(1, new SimpleDateFormat("yyyy-MM-dd")
.format(new Date()));
ps.setString(2, tt[0].trim());
ps.setString(3, tt[1].trim());
ps
.setString(4, new SimpleDateFormat("yyyy")
.format(new Date()));
ps.setString(5, String.valueOf(cal.get(Calendar.WEEK_OF_YEAR)));
a = ps.executeUpdate();
line = br.readLine();
}
System.out.println("a=" + a);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (ps != null) {
ps.close();
ps = null;
}
if (ct != null) {
ct.close();
ct = null;
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
}