how to insert current.date() + 14days into ms sql database as due_date.

and to check a feild enter in jsp form for availability

here are my codes but they are not working

codefor todays DATE: + 14 days

import java.text.DateFormat;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.Date;

// Get a Date object that represents 14 days from now

Date today =new Date();

cal.setTime(today);

cal.add(Calendar.DATE, 14);

Date expiration = cal.getTime();

2.Get availability of book as Y or N display the statment in the same jsp.

<%@page contentType="text/html" import="java.io.*,java.sql.*,javax.sql.*,java.util.*"%>

String lStrBookTitle = request.getParameter("booktitle");

System.out.println("BT "+lStrBookTitle);

String available ="N";

String bookavailable="N";

if(lStrBookTitle !=null && !lStrBookTitle.trim().equals(""))

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con = DriverManager.getConnection("jdbc:odbc:book","scott","tiger");

PreparedStatement pst = con.prepareStatement("select available from book_details where upper(document_title) like '%"+lStrBookTitle.toUpperCase()+"%'");

ResultSet rs = pst.executeQuery();

if(rs.next())

{

available = rs.getString("AVAILABLE");

bookavailable="Y";

}

}

catch(Exception e)

{

System.out.println("Error "+e);

}

}

else

{

lStrBookTitle="";

}

%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Book Borrower</title>

<script>

function fnSearch()

{

if(document.ChkAvailabilty.booktitle.value=="")

{

alert("Enter book title...");

returnfalse;

}

else

{

document.ChkAvailabilty.action="index.jsp";

document.ChkAvailabilty.method="post";

document.ChkAvailabilty.submit();

}

}

</script>

<script>

function ewms_action_validate(){

return ewms_validate();

}

function ewms_validate(){

returntrue;

}

function fnSearch(documentNo){

document.frmReturn.action =

"/wms/retrieve_lib_log?documentNo=" + documentNo;

document.frmReturn.target ="_top";

document.frmReturn.submit();

}

</script>

</head>

</body>

</html>

[4476 byte] By [hrushia] at [2007-11-27 0:02:30]
# 1

1. You didn't say how it isn't working.

2. You should have two classes. One class ONLY does JDBC. The other class does the GUI stuff.

3. This is a JDBC forum, not a GUI forum. So if your problem has anything at all to do with the GUI then you posted in the wrong place.

4. You are not doing anything with the date in regards to the database so of course it will have absolutely no impact. You certainly are not using 'expiration'.

jschella at 2007-7-11 15:54:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
hello, my need is to get 14 days added to current date and insert it into mysql db feild name due_date; so as to send reminder to the book_borrower
hrushia at 2007-7-11 15:54:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
When you create it or to update it.For the first you need to start by modifying your insert.If the second then you need to start by creating the update.
jschella at 2007-7-11 15:54:59 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...