aspose file tools*
The moose likes JDBC and the fly likes A simple  insert.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "A simple  insert...." Watch "A simple  insert...." New topic
Author

A simple insert....

Raymond O'Leary
Greenhorn

Joined: Mar 23, 2004
Posts: 24
....wrecking my head!
Anybody got any clue as to why it isn't working? When I click the submit button the page displayed only contains the text used in the finally bit.
"DisConnecting From Server.... "
It doesn't even get this far:

Here's my full code:

<%@ page language="java" import="java.sql.*, oracle.jdbc.*" contentType= "text/html; charset=windows-1257" %>
<html>
<BODY>
<%
Connection con = null;
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection("jdbc racle:thin:@witnt07.wit.ie:1521 rawit","x", "x");
if ( ( request.getParameter("submit")).equals("submit") )
{
Statement statement1 = con.createStatement();
String sup=(String) session.getAttribute("username");
String grp = request.getParameter("t1");
String day = request.getParameter("D2");
String month = request.getParameter("D3");
String year = request.getParameter("D4");
String com = request.getParameter("comment");
String strSQL = "INSERT INTO SUPERLOG VALUES(NEXTSUPERLOG.nextval , "+" '"+sup+"' , "+" '"+grp+ "' , "+" '"+ day+"' , " + " '" +month +"' , "+" '"+year+"'," + "'" +com +"')";
String strSQL1 = "commit";
statement1.executeQuery(strSQL);
statement1.executeQuery(strSQL1);
con.close();
out.println("<font color=midnightblue><h3>You're log was added</h3></font>");
}
}
catch (SQLException sqle) {
out.println("SQL Bummer : " + sqle.getMessage());
}

catch (Exception e) {
out.println("Bit of a Bummer : " + e.getMessage());
}
finally {
try
{
if ( con != null )
{
out.println("<BR><BR>");
out.println("DisConnecting From Server.... ");
con.close();
}
}
catch (Exception e)
{
out.println("Bit of a Bummer Disconnecting : " + e.getMessage());
}
}
%>
</CENTER>
</BODY>
</HTML>
[/CODE]
Anybody have any ideas?
Lu Battist
Ranch Hand

Joined: Feb 17, 2003
Posts: 104
Sure, I got an idea. Check the if statement, maybe its not true.
Try this:
if ( ( request.getParameter("submit")).equals("submit") ) {
out.println("Debug: inside if, add more debug statements around the query.");
...
} else {
out.println("Debug: inside else, guess I'd better re-check the request paramenters.");
}
Raymond O'Leary
Greenhorn

Joined: Mar 23, 2004
Posts: 24
Lu you're a genius,
now if you could only tell me why the text in my text area is not goning into the database then I may propose.
I just got rid of the if itself by the way. Is this a bad idea?
CHEERS!!
Raymond O'Leary
Greenhorn

Joined: Mar 23, 2004
Posts: 24
All working thanks very much
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

minor remark:
"You're log was added" isn't propper english.
It means "You are log was added" which isn't of much sense.
"Your log was added" is what you mean.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A simple insert....