This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Raymond O'Leary

Greenhorn
+ Follow
since Mar 23, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Raymond O'Leary

hi lads,
Not sure if this is in the correct place......but, I'm just wondering if there are any defined jsp coding and counting standards?
Or should i just stick to a predefined java one?
Would it be difficult to define my own standards?
Is there any rules of thumb I should follow?
Oh and in my code I have SQL statements reading/ writing etc to a database. Is this all done on the database side or in the jsp page?
Having a bit of difficulty finding stuff on the web.
Anyway thanks guys
18 years ago
JSP
All working now thanks for the help guys especialyy Avi!
Ray
All working now thanks for the help guys.
Ray
Ah its working now.
Thanks for your help buddy.
Yeah second query works perfectly
I put this in batween the selects, and the value is printed out.

Its this bit here! Does it look correct?
[ CODE]
String ans=null;
while(rs.next())
{
ans = rs.getString(1);
}
rs.close(); [/CODE]
and thanks for pointing out the closed rs1 for me.
Yeah it returns a value, my problem is putting that value into the string ans and using that value in a further sql statement.
Hey Guys me again!
Here I'm trying to store the sole result into a string called ans, and use the string in another query. as dar as i can tell the ans string isn't getting any values? Can anybody shed some light on this? Thanks guys.
All working thanks very much
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!!
....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?
Hey there,
So this will work? Cant get the bloody thing to run.
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";
ResultSet rs1 = statement1.executeQuery(strSQL);
rs1.close();
con.close();
Thanks for the help.
Hey Guys,
I'm trying to run a jsp application inside jbuilder? Everything compiles ok but after this:
Starting tomcat. Check logs/tomcat.log for error messages
2004-03-29 05:51:53 - ContextManager: Adding context Ctx( )
2004-03-29 05:51:54 - Ctx( ): Removing duplicate servlet jsp jsp(org.apache.jasper.servlet.JspServlet/null)
2004-03-29 05:51:54 - Ctx( ): Removing duplicate *.jsp -> jsp(org.apache.jasper.servlet.JspServlet/null)
2004-03-29 05:51:57 - PoolTcpConnector: Starting HttpConnectionHandler on 8080
2004-03-29 05:51:57 - PoolTcpConnector: Starting Ajp12ConnectionHandler on 8081
I just get this!
2004-03-29 05:52:02 - Ctx( ): IOException in: R( + / + null) Connection aborted by peer: socket write error

Its breaking my heart!
Any clues as to why this is happening?
Cheers.
Hey Guys,
I'm trying to run a jsp application inside jbuilder? Everything compiles ok but after this:
Starting tomcat. Check logs/tomcat.log for error messages
2004-03-29 05:51:53 - ContextManager: Adding context Ctx( )
2004-03-29 05:51:54 - Ctx( ): Removing duplicate servlet jsp jsp(org.apache.jasper.servlet.JspServlet/null)
2004-03-29 05:51:54 - Ctx( ): Removing duplicate *.jsp -> jsp(org.apache.jasper.servlet.JspServlet/null)
2004-03-29 05:51:57 - PoolTcpConnector: Starting HttpConnectionHandler on 8080
2004-03-29 05:51:57 - PoolTcpConnector: Starting Ajp12ConnectionHandler on 8081
I just get this!
2004-03-29 05:52:02 - Ctx( ): IOException in: R( + / + null) Connection aborted by peer: socket write error

Its breaking my heart!
Any clues as to why this is happening?
Cheers.
18 years ago
JSP
Ok this is what I've got but it still dont work, can anybody shed any light on this? I'm just unsure of the format of some of the statements.

<%@ page language="java" contentType="text/html"
import="java.util.*" import="oracle.jdbc.*" import="java.sql.*"%>
<html>
<body bgColor="WHITE" text = "MIDNIGHTBLUE">
<img src="witlogo.gif" align=left><H2><font color=midnightblue>X</font></H2><hr>
<%
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con = DriverManager.getConnection("jdbc racle:thin:@witnt07.wit.ie:1521 rawit","X", "X");
String query = "INSERT INTO SUPERLOG VALUES ('',?,?,?,?,?,?)";
PreparedStatement Stmt = con.prepareStatement(query);

String UName = (String) session.getAttribute("username");
Stmt.setString(1,NEXTSUPERLOG.nextval);
Stmt.setString(2,request.getParameter("UName"));
Stmt.setString(3,request.getParameter("t1"));
Stmt.setString(4,request.getParameter("D2"));
Stmt.setString(5,request.getParameter("D3"));
Stmt.setString(6,request.getParameter("D4"));
Stmt.setString(7,request.getParameter("comment"));
Stmt.executeUpdate();
Stmt.close();
con.close();
%>
<p> <br><p> <br><p> <H3><b>Your Comment Was Successfully Added</b></h3>
</body>
</html>
Thanks Lads
Hey There,
I've put an auto increment into my database for updating some of my tables.
When using preparedStatements I know that you dont put in a question mark in the insert statement, but what does one put in there?
This is the code and assume that the auto incfrement is the first field in the table.
String query = "INSERT INTO SUPERLOG VALUES (?,?,?,?,?,?,?)";
And when doing the -
Stmt.setString(1,"");
-stuff do you leave one blank? Or do you leave it out altogether?
Here is the code...

String query = "INSERT INTO SUPERLOG VALUES (?,?,?,?,?,?,?)";
PreparedStatement Stmt = con.prepareStatement(query);
String UName = (String) session.getAttribute("username");
Stmt.setString(1,"");
Stmt.setString(2,request.getParameter("UName"));
........
Stmt.setString(6,request.getParameter("xxx"));
Thanks guys.