【转贴】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.
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.
相关文章推荐
- Property 'date' not found on type java.lang.String] with root cause解决方案
- Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'xxx'
- java存储时间date到mysql的datetime格式的方法
- Insert Date and Time into Access
- 使用Hibernate轻松解决java中date与datetime类型不兼容的问题
- Spring 整合 Flex (BlazeDS)无法从as对象 到 Java对象转换的异常:org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.Date' to required type 'java.sql.Timestamp' for property 'wfsj'; nested exception is java.lang.Ill
- Cause: java.sql.SQLException: 无效的列类型: 1111(Mybatis中insert插入空值时,需要指定JdbcType)
- Failed to convert from type java.lang.String to type java.util.Date for value………解决办法
- 问题已解决,at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:81)
- 使用Hibernate轻松解决java中date与datetime类型不兼容的问题
- FSM3.1-RROR: insert into j_mztj(TID,Person0,Person1,TJBZ,TJDate,TJDeptName,AgentID,AgentName,DeptID,DeptName,RecordTime,DataType)values('2014041410403
- org.hibernate.MappingException: Could not determine type for: java.utils.Date
- Java Date和MySQL datetime数据类型转换
- java.sql.SQLException: Column count doesn't match value count at row 1 Query: insert into category values(null,?,?,?) Parameters: [1111111, 1111, 软件]
- java中将type=date的时间转换成北京时间,并返回字符串型
- (转)java datetime date 类型
- Caused by: java.sql.BatchUpdateException: ORA-01461: can bind a LONG value only for insert into a LO
- Oracle insert into date fileld
- mssql insert into等数据更新操作
- mssql-异常value '0000-00-00' can not be represented as java.sql.Date