Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

how do i insert into databse?

 
   Database Forums (Home) -> Java RSS
Next:  want to get content of one php file in another ph..  
Author Message
mak1084

External


Since: Feb 16, 2008
Posts: 1



(Msg. 1) Posted: Sat Feb 16, 2008 6:14 am
Post subject: how do i insert into databse?
Archived from groups: comp>lang>java>databases (more info?)

i'm creating a an web application on attendance, in which a user
after selecting the subject and month he gets all the student info
who
has taken that subject.

my problem is i'm able to get the multiple student with the text box
where a user can put up his monthly attendance. how do i insert the
info in database...at the same time after filling the info.

the snapshot of the code is here...
here I'm getting the roll no. along with the text box..

[code]
String str1 = "select roll_no from student where sem_id = (select
sem_id from subject where course_id ='bsc_it' and sub_id =
'"+getsub1+"')";

ResultSet rs = stmt.executeQuery(str1);
%>
<table
align="center" width="" cellpadding="0" cellspacing="0"
border="1" cellspacing="1" cellpadding="1">

<tr>

<td><input type="text" value="Total Lecture" readonly=""/></
td>

<td><input type="text" name="total_att" maxlength="2"></td>

</tr>

<tr>

<td><input type="text" value="Student roll no." readonly="" /
></td>


</tr>

<% while(rs.next())


{

%>


<%

stu_roll = rs.getString("roll_no");

%>

<tr bordercolor="#CC3366">

<td>

<%

out.println(stu_roll);

%>

</td>

<td>

<input type="text" name="att" />

</td>

</tr> 

<%
}


con.close();
}

catch(SQLException e)

{

out.println("Exception in SQL" + e);
}
%>
[/code]

 >> Stay informed about: how do i insert into databse? 
Back to top
Login to vote
Robert Kochem

External


Since: Feb 16, 2008
Posts: 1



(Msg. 2) Posted: Sat Feb 16, 2008 11:00 am
Post subject: Re: how do i insert into databse? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

schrieb:

> [code]
> String str1 = "select roll_no from student where sem_id = (select
> sem_id from subject where course_id ='bsc_it' and sub_id =
> '"+getsub1+"')";

Please don't forget that creating SQL queries with user specified input
incorporates the possibility for an SQL injection attack. Therefore I
strongly recommend to change your code to use a PreparedStatement and set
the parameters via setInt() or SetString() - then your WebApp is secure
against such attacks.

http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html

Robert

 >> Stay informed about: how do i insert into databse? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
insert....select - I'm using JDK 1.5.0.3, Sybase JConnect for JDBC version 5.5, connecting to Sybase Adaptive Server Enterprise version 12.5. Here's a SSCCE: import java.sql.*; public class TestJDBC { public static void main(String[] args) { String URL =..

How to insert a string that contains ' or , - Hello, i am using the following statement to insert a message from a user into the database. updStmt.executeUpdate("INSERT INTO Contact (uId, replyAddr, subject, msg) "+ "VALUES (" + userId + ",&q...

Hibernate-MySQL Insert problem - Hi, I have a Hibernate 2 application that has worked continuously for about a year running on OS X with MySQL. Now we need to deploy it for a different customer on Windows, and it is failing, specifically, it can read from the database fine, but upon..

Insert speed (JDBC and MySQL) - Hi, I am writing a program that needs to typically carry out around 100,000 INSERTs to a mysql database. I would normally load the data using a text file, but in this case, there is the occasional query required (evenly spread through, and dependent....

Bulk Insert jdbc oracle - Hey i am writing a java program which will insert more than 1,00,000 records in to oracle DB. i have read the records from a txt file , i can read it using java and load one by one record into oracle using executeUpdate(), but i want know is there any wa...
   Database Forums (Home) -> Java All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]