Hi All,
I am a very novice at the servlets, just started on them a week ago,
I am using Oracle 8.1.6 as a database, and iPlanet web server.
Here is my code, i am having problem with fetching the date and setting it
in the database.
I'll appreciate if someone can help.
-----------
import java.io.*;
import java.sql.*;
import java.sql.Date;
import java.math.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;
import nani.xml.*;
public class NanAccountL
extends NanXmlServlet
{
private ResourceBundle _rsrc = null;
//-------------------------------------------------------------------
// Function Name: init()
//-------------------------------------------------------------------
public void
init(
ServletConfig config
)
throws ServletException
{
super.init(config);
_rsrc = ResourceBundle.getBundle("NanAccountRes");
}
//-------------------------------------------------------------------
// Function Name: doRequest ()
//-------------------------------------------------------------------
public void
doRequest(
String path,
HttpServletRequest req,
HttpServletResponse res
)
throws IOException
{
ByteArrayOutputStream str = new
ByteArrayOutputStream(256);
PrintWriter out = new PrintWriter(str, true);
xmlHeader(out);
if (path.equals("NewAccount"))
{
doNewAccount(req, out);
}
else if (path.equals("UpdAccount"))
{
doUpdAccount(req, out);
}
else if (path.equals("DelAccount"))
{
doDelAccount(req, out);
}
else if (path.equals("GetAccount"))
{
doGetAccount(req, out);
}
else
{
xmlErr(out, null, "INVALID_PATH", path);
}
out.close();
xmlBody(res, str);
}
---------------------------------------------------
** in the following script getdecparameter and getstringparameter are
userdefined functions
// starting newaccount
//-------------------------------------------------------------------
// Function Name: doNewAccount ()
//-------------------------------------------------------------------
private void
doNewAccount(
HttpServletRequest req,
PrintWriter out
)
throws IOException
{
Long ses = null;
Long pact = null;
Long conId = null;
String dAlias = null;
String login = null;
Long pwd = null;
String dsbl = null;
Long trmId = null;
Date ExDte = null;
ses = getDecParameter("Ses", 1, 10, req, out, null, false);
pact = getDecParameter("Pact", 1, 255, req, out, null,
true);
conId = getDecParameter("ConId", 1, 255, req, out, null,
false);
dAlias = getStringParameter("DAlias", 1, 255, req, out,
null, true);
login = getStringParameter("Login", 1, 255, req, out, null,
true);
pwd = getDecParameter("Pwd", 1, 255, req, out, null, false);
dsbl = getStringParameter("Dsbl", 1, 255, req, out, null,
false);
trmId = getDecParameter("Trm", 1, 255, req, out, null,
true);
* ExDte = getDate("ExDte");
if ((ses!=null) && (conId!=null) && (pwd!=null) &&
(dsbl!=null))
{
execNewAccount(ses, pact, conId, dAlias, login, pwd,
dsbl, trmId, ExDte, out);
}
}
//-------------------------------------------------------------------
// Function Name: execNewAccount()
//-------------------------------------------------------------------
private void
execNewAccount(
Long ses,
Long pacc,
Long conId,
String dAlias,
String login,
Long pwd,
String dsbl,
Long trmId,
Date ExDte,
PrintWriter out
)
throws IOException
{
CallableStatement cs = null;
int rc = 0;
int num = 0;
try{
cs = _con.prepareCall("{?=call
PkgAccount.NewAccount(?,?,?,?,?,?,?,?,?,?,?)}");
cs.registerOutParameter(1, java.sql.Types.INTEGER);
cs.registerOutParameter(11, java.sql.Types.INTEGER);
cs.registerOutParameter(12, java.sql.Types.INTEGER);
if (ses != null)
cs.setLong(2, ses.longValue());
else
cs.setNull(2, java.sql.Types.INTEGER);
-
-
-
-there is some more code here
-
-
cs.setString(8, dsbl);
if (trmId != null)
cs.setLong(9, trmId.longValue());
else
cs.setNull(9, java.sql.Types.INTEGER);
* cs.setDate(10, ExDte);
execute(cs);
rc = cs.getInt(1);
num = cs.getInt(11);
cs.close();
cs = null;
switch (rc)
{
case 0:
out.println("<VALUE int=\"" + num + "\"/>");
xmlErr(out, _rsrc,
"SUCCESSFUL_OBJECT_CREATION");
break;
case 1:
xmlErr(out, _rsrc,
"BAD_SESSION_ID");
break;
case 2:
xmlErr(out, _rsrc,
"NOT_AUTHORIZED");
break;
case 3:
xmlErr(out, _rsrc,
"BAD_PARENT_ACCOUNT");
break;
case 4:
xmlErr(out, _rsrc, "BAD_CON_ID");
break;
case 5:
xmlErr(out, _rsrc,
"NULL_LOGIN_VAL");
break;
case 6:
xmlErr(out, _rsrc,
"BAD_PASSWORD_ID");
break;
case 7:
xmlErr(out, _rsrc,
"BAD_DISABLE_VAL");
break;
case 9:
xmlErr(out, _rsrc,
"BAD_TERMINAL_ID");
break;
default:
xmlErr(out, null, "SYSERR");
break;
}
}
catch (SQLException e)
{
xmlErr(out, null,"SYSERR");
e.printStackTrace(out);
logSqlException("PkgAccount.NewAccount failed", e);
}
finally
{
closeAll(cs, null, null);
}
}
TIA
Geeta Kaushal
[EMAIL PROTECTED]
PH: (204) 487-5000 ext 285
IC Group Inc.
383 Dovercourt Drive
Winnipeg, Manitoba
Canada
R3Y 1G4
--------------------------------------------
This email, together with any attachments, is for the exclusive and
confidential use of the addressee(s). Any other distribution, use or
reproduction without the sender's prior consent is unauthorized and
strictly prohibited. If you have received this message in error, please
notify the sender by email immediately and delete the message from your
computer without making any copies.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html