• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help needed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys here...igot a minor problem and im sure you guys will easily figure it out..coz im new to programming...
currently i just wan a simple form that can store datas into an oracle database called toad.i hav simply 2 pages, one is appsform.jsp and the other is appsdata.jsp

but i cant seem to put those values into the toad table in the database..can u guys help me figure out wads wrong?

appsform.jsp
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>


<html>
<body>
<br>
<center>
<p>
<u><b><font size="5">For Applicating DepartMent</font></b></u>
</p>
<form method="post" action="appsdata.jsp" >
<table border="0">
<tr>
<td>Employee's Full name</td>
<td>
<input name="employee_name" value="" size="30"/>
</td>
</tr>
<tr>
<td>Employee's number</td>
<td>
<input name="employee_number" value="" size="30"/>
</td>
</tr>
<tr>
<td>Department</td>
<td>
<input name="department" value="" size="30"/>
</td>
</tr>
<tr>
<td>Designation</td>
<td>
<input name="desgination" value="" size="30"/>
</td>
<tr>
<td>Telephone Extension</td>
<td>
<input name="telephone_extension" value="" size="30"/>
</td>
<tr>
<td>Name of Superior</td>
<td>
<input name="name_of_superior" value="" size="30"/>
</td>
<tr>
<td>Account Effect Date</td>
<td>
<input name="account_effective_date" value="" size="30"/>
</td>


<tr>
<td>Domain Access (Yes/No): </td>


<tr>
<td>Shared Drive (S):</td>
<td>
<input type="radio" name="shared_drive_flag" value="yes">Yes
<input type="radio" name="shared_drive_flag" value="no">No
</td>

<tr>
<td>Department Drive (G):</td>
<td>
<input type="radio" name="dept_drive_flag">Yes
<input type="radio" name="dept_drive_flag">No
</td>
<tr>
<td>Other Drives</td>
<td>
<input type="radio" name="other_drive_flag">Yes
<input type="radio" name="other_drive_flag">No
</td>


<tr>
<td></td>
<td>If yes, pls state: <input name="other_drives" value="" size="30"/></td>

<tr>
<tr>
<td>Kermit System</td>
<td>
<input type="radio" name="kermit_access_flag">Yes
<input type="radio" name="kermit_access_flag">No
</td>
<tr>
<tr>
<td>Internet Access</td>
<td>
<input type="radio" name="internet_access_flag">Yes
<input type="radio" name="internet_access_flag">No
</td>
<tr>
<tr>
<td>Email Account</td>
<td>
<input type="radio" name="email_flag">Yes
<input type="radio" name="email_flag">No
</td>
<tr>
<tr>
<td>Oracle Account</td>
<td>
<input type="radio" name="oracle_flag">Yes
<input type="radio" name="oracle_flag">No
</td>
<tr>
<tr>
<td>Discoverer Account</td>
<td>
<input type="radio" name="discoverer_flag">Yes
<input type="radio" name="discoverer_flag">No
</td>
<tr><tr>
<td>*Remote Access to office network</td>
<td>
<input type="radio" name="remote_access_flag">Yes
<input type="radio" name="remote_access_flag">No
</td>

<tr>
<td>Requested By:</td>
<td>
<input name="requested_by" value="" size="30"/>
</td>
<tr>
<td>Request Date</td>
<td>
<input name="request_date" value="" size="30"/>
</td>

</table>


<br>
<input type="submit" value="Submit"/>
<input type="reset" value="Clear"/>
</form>
</center>
</body>
</html>


appsdata.jsp

<%@ page language="java"%>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>

<%
Connection con = null;
Statement stmt = null;
ResultSet rs = null;


String employee_name=request.getParameter("employee_name");
String employee_number=request.getParameter("employee_number");
String department=request.getParameter("department");
String designation=request.getParameter("designation");
String telephone_extension=request.getParameter("telephone_extension");
String name_of_superior=request.getParameter("name_of_superior");
String account_effective_date=request.getParameter("account_effective_date");
String shared_drive_flag=request.getParameter("shared_drive_flag");
String dept_drive_flag=request.getParameter("dept_drive_flag");
String other_drive_flag=request.getParameter("other_drive_flag");
String other_drives=request.getParameter("other_drives");
String kermit_access_flag=request.getParameter("kermit_access_flag");
String internet_access_flag=request.getParameter("internet_access_flag");
String email_flag=request.getParameter("email_flag");
String oracle_flag=request.getParameter("oracle_flag");
String discoverer_flag=request.getParameter("discoverer_flag");
String remote_access_flag=request.getParameter("remote_access_flag");
String requested_by=request.getParameter("requested_by");
String requested_date=request.getParameter("requested_date");

String querytext = "INSERT INTO sshl_account_application VALUES('"+employee_name+"','"+employee_number+"','"+department+"','"+designation+"','"+telephone_extension+"','"+name_of_superior+"','"+account_effective_date+"','"+shared_drive_flag+"','"+dept_drive_flag+"','"+other_drive_flag+"','"+other_drives+"','"+kermit_access_flag+"','"+internet_access_flag+"','"+email_flag+"','"+oracle_flag+"','"+discoverer_flag+"','"+remote_access_flag+"','"+requested_by+"','"+requested_date+"')";



try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc racle:thin:@15.12.88.202:1522:test", "apps", "apps");
stmt = con.createStatement();
rs = stmt.executeQuery(querytext);
} catch (Exception e) {


%>

<%@ include file="fail.jsp"%>

<%

}

response.sendRedirect("success.jsp");

%>
[ July 30, 2004: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Print ur querytext before calling executeQuery(). Just see whether the insert string formed is correct or not.
Also add a line e.printStackTrace() in ur exception block.
Hope u will get a solution after this.

----
Atul
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It'll be easier to figure out the error if you specify what problem you are facing.. Coding seems to be all rite..

Pranit..
 
mary bate
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thx guys..atul i will try use ur method ltr..thx a lot..
the problem im facing rite now is that...when i enter values in the form and click submit, it can process to the page called success.jsp but when i look at the toad database, the table is empty...

any ideas?
 
Atul Prabhu
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mary,

This is just a wild guess. Hope this solves ur problem.




w.r.t to ur code if there is a exception it would include fail.jsp content into ur current jsp page.
But just after the exception block u have given response.sendRedirect(). So even if there is a exception the code would redirect it to success.jsp.
Try placing response.sendRedirect() in the try block.

Hope this works.

---
Atul
 
mary bate
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thx guys sorry, sorry for late reply..i've been tired trying all the solutions but to no avail...is toad oracle database doesnt evolve in a full blown jdbc components like one guy says or isit tt my codes aint right?

help needed...
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the JDBC forum.
 
Atul Prabhu
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mary,

Did u try placing response.sendRedirect()in the try block. Or did u write a println statement in the exception block. There is problem in the code. Please do try this.U cant just blindly say the codes not working, u have to try all posssible combination.

---
Atul
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mary,

What you need to do is try to narrow down where the problem may be. Put some 'System.out.print' statements to see whether the correct parameters are being passed, whether any exceptions are being thrown etc.

Put an exception.printStackTrace(System.out) in your catch block, so you know what exceptions if any are being thrown. If everything else is ok, and only the database is not being updated, you could be getting a SQLException
 
mary bate
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi atul,

u mean this? placing system.out.println(request.getparameter("Employee_name")); {




try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc racle:thin:@15.12.88.202:1522:test", "apps", "apps");
stmt = con.createStatement();
rs = stmt.executeQuery(queryText);
} catch (Exception e)
system.out.println(request.getparameter("Employee_name")); {


im not good at this..pls correct me or excuse me..
 
mary bate
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi sonny,

u mean placing this exact statement?


try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc racle:thin:@15.12.88.202:1522:test", "apps", "apps");
stmt = con.createStatement();
rs = stmt.executeQuery(querytext);
} catch (Exception e)
exception.printStackTrace(System.out){
 
Atul Prabhu
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mary,

Could u please replace your code by the one as given below :

try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc racle:thin:@15.12.88.202:1522:test", "apps", "apps");
stmt = con.createStatement();
rs = stmt.executeQuery(querytext);
response.sendRedirect("success.jsp");

} catch (Exception e) {

e.printStackTrace();
%>

<%@ include file="fail.jsp"%>

<%

}

This should work. Please check if there are any error messages in the back end.If there is any exception please do inform.

Regards
Atul
 
mary bate
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi atul,


try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc racle:thin:@15.12.88.202:1522:test", "apps", "apps");
stmt = con.createStatement();
rs = stmt.executeQuery(querytext);
response.sendRedirect("success.jsp");

} catch (Exception e) {

e.printStackTrace();
%>

<%@ include file="fail.jsp"%>

}


i got these errors, it seems i cant capture any data from the form as i use a println statement..it shows a blank page...

Line 119 '}' expected. }

Line 120 'try' without 'catch' or 'finally'. private static class __jsp_StaticText {

Line 120 Statement expected. private static class __jsp_StaticText {
 
Atul Prabhu
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mary,

Try this code scriptlet tag was missing)

try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc racle:thin:@15.12.88.202:1522:test", "apps", "apps");
stmt = con.createStatement();
rs = stmt.executeQuery(querytext);
response.sendRedirect("success.jsp");

} catch (Exception e) {

e.printStackTrace();
%>

<%@ include file="fail.jsp"%>

<%
}
%>

Please inform if problem still exists.

Regards
Atul
 
mary bate
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi atul,

theres this error, but i already declared rs..

Line 82 Undefined variable: querytext rs = stmt.executeQuery(querytext);

Connection con = null;
Statement stmt = null;
ResultSet rs = null;
 
Atul Prabhu
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Line 82 Undefined variable: querytext rs = stmt.executeQuery(querytext);

This is telling you that querytext is undefined. And not rs(Resultset).

Check whether you have declared querytext...

Note:
if you have any further problem i am online on yahoo (prabhu_atul@yahoo.com)You can buzz me.

Regards
Atul
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic