473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Help insert SQL query in jsp page

15
Kindly please anyone here helps me how to check in my program,

i want to insert this SQL query to jsp file:

SELECT COUNT(id) new
FROM annaudio
WHERE id NOT IN (
SELECT annaudio_id FROM annread WHERE annuser_id=1
)


and this is my jsp file's script:
<%
Class.forName ("org.gjt.mm.mysql.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ann?user=root");
Statement statement = connection.createStatement();

ResultSet rs = statement.executeQuery("SELECT COUNT(id) FROM annaudio WHERE id NOT IN(SELECT annaudio_id FROM annread WHERE annuser_id=" + "iduser)");

out.println(rs);
%>

My problem is how to display my "ResultSet"??
Jun 4 '07 #1
6 10907
Motoma
3,237 Expert 2GB
I have moved this thread to the Java forum, hopefully they will have some knowledge on the subject.
Jun 4 '07 #2
dmjpro
2,476 2GB
Did u see the SUN API Documentation of ResultSet interface?
If u did then there would be no problem.
Best of luck.

Kind regards,
Dmjpro.
Jun 5 '07 #3
r035198x
13,262 8TB
Kindly please anyone here helps me how to check in my program,

i want to insert this SQL query to jsp file:

SELECT COUNT(id) new
FROM annaudio
WHERE id NOT IN (
SELECT annaudio_id FROM annread WHERE annuser_id=1
)


and this is my jsp file's script:
<%
Class.forName ("org.gjt.mm.mysql.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ann?user=root");
Statement statement = connection.createStatement();

ResultSet rs = statement.executeQuery("SELECT COUNT(id) FROM annaudio WHERE id NOT IN(SELECT annaudio_id FROM annread WHERE annuser_id=" + "iduser)");

out.println(rs);
%>

My problem is how to display my "ResultSet"??
Read sun's jdbc tutorial and see how to use resultsets. You probably won't take long to grasp it because it really is very simple.
Jun 5 '07 #4
Read sun's jdbc tutorial and see how to use resultsets. You probably won't take long to grasp it because it really is very simple.
SELECT COUNT(id) new
FROM annaudio
WHERE id NOT IN (
SELECT annaudio_id FROM annread WHERE annuser_id=1
)


and this is my jsp file's script:
<%
Class.forName ("org.gjt.mm.mysql.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ann?user=root");
Statement statement = connection.createStatement();

ResultSet rs = statement.executeQuery("SELECT COUNT(id) FROM annaudio WHERE id NOT IN(SELECT annaudio_id FROM annread WHERE annuser_id=" + "iduser)");

out.println(rs);
%>

My problem is how to display my "ResultSet"??


Integer retval = getInteger(rs, 1);

out.println( retval);
Jun 6 '07 #5
r035198x
13,262 8TB
SELECT COUNT(id) new
FROM annaudio
WHERE id NOT IN (
SELECT annaudio_id FROM annread WHERE annuser_id=1
)


and this is my jsp file's script:
<%
Class.forName ("org.gjt.mm.mysql.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ann?user=root");
Statement statement = connection.createStatement();

ResultSet rs = statement.executeQuery("SELECT COUNT(id) FROM annaudio WHERE id NOT IN(SELECT annaudio_id FROM annread WHERE annuser_id=" + "iduser)");

out.println(rs);
%>

My problem is how to display my "ResultSet"??


Integer retval = getInteger(rs, 1);

out.println( retval);
If you wont go through the tutorial then at least take time to read the resultset specs.
Jun 6 '07 #6
praveen2gupta
201 100+
Kindly please anyone here helps me how to check in my program,

i want to insert this SQL query to jsp file:

SELECT COUNT(id) new
FROM annaudio
WHERE id NOT IN (
SELECT annaudio_id FROM annread WHERE annuser_id=1
)


and this is my jsp file's script:
<%
Class.forName ("org.gjt.mm.mysql.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ann?user=root");
Statement statement = connection.createStatement();

ResultSet rs = statement.executeQuery("SELECT COUNT(id) FROM annaudio WHERE id NOT IN(SELECT annaudio_id FROM annread WHERE annuser_id=" + "iduser)");

out.println(rs);
%>

My problem is how to display my "ResultSet"??

execution of the above query will fetch only one record in the resultset. To print
the value of the resultset you should use request.getParameter("count(id)") will be displaying the output on the page.
Jun 7 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: AMD Desktop | last post by:
Here is the table: CREATE TABLE ( IDENTITY (1, 1) NOT NULL , NOT NULL , NOT NULL , NOT NULL CONSTRAINT DEFAULT (0), NOT NULL , NOT NULL ) ON
2
by: avinash | last post by:
hello myself avinash i am developing on application having vb 6 as front end and sql server 7 as back end. when i use insert query to insert data in table then the date value of that query is...
8
by: Carl | last post by:
Hi, I hope someone can share some of their professional advice and help me out with my embarissing problem concerning an Access INSERT query. I have never attempted to create a table with...
0
by: Daves | last post by:
(using 2.0) I have a page for viewing products and each product is assigned to several categories. On this page I have a FormView and an AccessDataSource. The ItemTemplate shows the product...
1
by: kiny3k | last post by:
hi, i have written this insert query for inserting data in database : "insert into leavemaster (leave_code,leave_desc,leave_type, leave_days, leave_valid_month, leave_amount, effective_date,...
3
by: star111792 | last post by:
hi, i have just started learning ASP. i m doing database connectivity in ASP. my problem is with the insert query. i have a page "form.asp" for taking input from user. after entering data...
1
by: billypit | last post by:
Hi, In my project i have one table production.Now i have to make application in which i have to insert new data in table by fields of form made in access.I don't know how to use form field's values...
0
by: magnolia | last post by:
i created a trigger that will record the changes made to a table .everything works fine except the insert query.whenerever i try to insert a record it fires insert and update triger at the same time...
2
bard777
by: bard777 | last post by:
I have a form kicking off an INSERT query. I need to check another table for a matching value and use a field from that table as the value for one of the fields in my insert. Table 1 (insert from...
2
by: gabielmatos | last post by:
this is my query; string NPI = fields.GetValue(0).ToString(); string EntiType = fields.GetValue(1).ToString(); string ProvLastNameLegal = ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.