Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 15th, 2006, 12:52 AM
Authorized User
Join Date: Dec 2003
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;
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(?,?,?,?,?,?,?,?,?,?,?,?,?)");
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);
int phoneno=Integer.parseInt(t4.getText());
java.util.Date d1 = new SimpleDateFormat("dd/MM/yyyy").parse(t11.getText());
java.sql.Date sqlDate1=new java.sql.Date(d1.getTime());

pstmt.setInt(13, 1);
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?

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

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.