您的位置:首页 > 编程语言 > Java开发

【转贴】Insert Java Date type into MSSQL’s datetime

2008-02-02 15:12 459 查看
转自:
http://iraniweb.com/blog2/?p=5
Seems a little ugly for what it does, but hey it’s OO-fantastic.

Statement stmt = null;

Connection con = null;

try

{

Class.forName(”com.microsoft.sqlserver.jdbc.SQLServerDriver”);

con = DriverManager.getConnection(connectionURL);

stmt=con.createStatement();

java.text.DateFormat df = new java.text.SimpleDateFormat(”MM/dd/yyyy”);

String startDate = df.format(date_var);

stmt.executeUpdate(”INSERT INTO XX (day_entry) VALUES (’” + startDate + “‘);”);

}

catch(Exception e)

{

System.out.println(query);

e.printStackTrace();

}

finally

{

}

This entry was posted on Thursday, May 17th, 2007 at 5:22 pm and is filed under Java, MSSQL. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐