java 与access数据库(200分)

  • 主题发起人 主题发起人 sunze
  • 开始时间 开始时间
S

sunze

Unregistered / Unconfirmed
GUEST, unregistred user!
各位同仁:
我使用java无法录入Date.Time型数据,请多帮助不胜感激
附:
static void addDatabase()
{
try
{
connection=DriverManager.getConnection("jdbc:odbc:ciflog");
java.util.Date datetmp=new java.util.Date();
java.util.Date dateday=new java.util.Date();

String S_year=datetmp.getYear()+1900+"/";
S_year+=datetmp.getMonth()+"/";
S_year+=datetmp.getDay();

String S_day=datetmp.getHours()+":";
S_day+=datetmp.getMinutes()+":";
S_day+=datetmp.getSeconds();

java.sql.Date testdate=new java.sql.Date(01,2,9);
java.sql.Time testtime=new java.sql.Time(17,5,4);

String sql="insert into ciflog(time) Values(18:00)";
//String sql="insert into ciflog(dat,time,ip,user,action) Values(?,?,'','','')";
//String sql="insert into ciflog(dat,time,ip,user,action) Values(1999-9-8, ,'df','df','df')";

System.out.println(testdate);

//String sql="Insert Into ciflog(dat,time,ip,user,action) values(1899-09-08,ValueOf(S_day),'10.122.34.1','sun','get files')";

statement=connection.prepareStatement(sql);
/* statement.setString(3,"12.2.3.1");
statement.setString(4,"sun85");
statement.setString(5,"get something");
*/
//statement.setDate(1,new java.sql.Date(1,9,7));

statement.executeUpdate();

statement.close();
connection.close();
}
catch(SQLException e)
{

System.out.println(e.toString());
}
/////////////////////////////////////////////////////////////////////
}//end function
 
http://www2.wjjsoft.com/docs/java/java0114.html
java.util.Date today = new java.util.Date();
java.sql.Date sqlToday = new java.sql.Date(now.getTime());
PreparedStatement p = theConn.prepareStatement("select * from cust where purchase_date < ?");
p.setDate(1, sqlToday);
ResultSet rs = p.executeQuery();
 
后退
顶部