Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 15th, 2006, 12:52 AM
Authorized User
 
Join Date: Dec 2003
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Best method to store date & Time with SQL 2000

These are the JFormatted Text Fields from where I get the data. By default I display Today's data and will be changed by user later.

l11= new JLabel("Passport Date Of Expiry");
t11 = new JFormattedTextField(new SimpleDateFormat("dd/MM/yyyy"));
t11.setValue(new Date());
l12= new JLabel("Time of Entry");
t12 = new JFormattedTextField(new SimpleDateFormat("KK:mm "));
t12.setValue(new Date());
l9= new JLabel("Visiting Pass: Date Of Issue");
t9 = new JFormattedTextField(new SimpleDateFormat("dd/MM/yyyy"));
t9.setValue(new Date());
l10= new JLabel("Visiting Pass:Date Of Expiry");
t10 = new JFormattedTextField(new SimpleDateFormat("dd/MM/yyyy"));
t10.setValue(new Date());

This is actually the insertion code:
int len;
String query,query1;
java.sql.PreparedStatement pstmt,pstmt1;
try
{
File file = new File(img);
FileInputStream fis = new FileInputStream(file);
len = (int)file.length();
query=("insert into visitor (Filename,length,photo,category,name,Address,Telep honeNo,PurposeOfVisit,VisitingOfficial,Nationality ,PassportNo,PassportDateOfExpiry,tag) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)");
//Filename,length,photo,
pstmt = conn.prepareStatement(query);
pstmt.setString(1,file.getName());pstmt.setInt(2, len);
// Method used to insert a stream of bytes
pstmt.setBinaryStream(3, fis, len);
pstmt.setString(4,t1.getText());
pstmt.setString(5,t2.getText());
pstmt.setString(6,t3.getText());
int phoneno=Integer.parseInt(t4.getText());
pstmt.setInt(7,phoneno);
pstmt.setString(8,t5.getText());
pstmt.setString(9,t6.getText());
pstmt.setString(10,t7.getText());
pstmt.setString(11,t8.getText());
java.util.Date d1 = new SimpleDateFormat("dd/MM/yyyy").parse(t11.getText());
java.sql.Date sqlDate1=new java.sql.Date(d1.getTime());
System.out.println(sqlDate1);
pstmt.setDate(12,sqlDate1);
pstmt.setString(13,t12.getText());
pstmt.setString(14,t9.getText());
pstmt.setString(15,t10.getText());

pstmt.setInt(13, 1);
pstmt.executeUpdate();
}
When I compile, there is no error. When I execute, it gives an exception, "optional feature not implemented". I've tested that it is only the problem with Date and Time Fields. Individually, I've tested for image,integer and string. It is working fine. Which is the best way to do this?
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Server Date & Time RICHBIRD Beginning VB 6 3 November 15th, 2007 08:59 AM
store insert/update date/time stamp in sql2k db alexdcosta ASP.NET 2.0 Basics 0 June 22nd, 2006 05:44 AM
how to get current date & time from client machine swati_joshi ASP.NET 1.0 and 1.1 Basics 2 April 28th, 2006 10:18 AM
how to store file in sql server 2000 database vivekkumar_23 SQL Server 2000 1 February 27th, 2006 10:41 PM
Date Time - From & To Passing shrishankaraan Crystal Reports 0 May 26th, 2004 10:28 PM



All times are GMT -4. The time now is 04:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.