Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MS Access data insert problem

 
aparna rudra
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hiii
this is the program in servlets for inserting data in database. the program compiles but no data is inserted. can anyone help me in solving this problem.



[ added code tags, fixed smilie problem - Dave ]

[ October 26, 2004: Message edited by: David O'Meara ]

[ edit again to give it a meaningful subject name ]
[ September 21, 2005: Message edited by: David O'Meara ]
 
Srinivasan Madhavan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Aparna,

Just check the method attribue of the form from where you get the parameters ( 'flyfrom; ....etc). May be the form method is a POST and hence your servlet may not have called the doGet() method at all !!!

If this is not the case then try the age old method of giving System.out.println() inside the doGet() methid and find out where thy problem is

Best Regards,
Srini
 
aparna rudra
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hii srini

thanks for ur reply, i got the values from html and the values got printed. i donot know the problem, been trying out from past 3 days.

please any one help me. i donot understand where the problem is? i am using JBuilder software.

plzzz anyone help me.
 
Priyadharshini Nagarajan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

the Drivermanager.getConnection should be

DriverMagare.getconnection("jdbc dbc ata source name");

1. Be sure that the query is executing properly by checing that in sql server.
2. if it is fine use the execute method to execute the inser statement
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Are you getting any exception.
2. What is auto commit mode of Connection.
3. I dont see any commit in your code
4. what dose printStackTrace say (on which line number null point exception occurs)
5. What is followling code print
System.out.println("values u enetered are:" + i);

6. REMOVE the trim() after request.getParameter("____").trim()

seems some of your parameter is null and you are applying trim on same.

7. Check your connection if it is null or not
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aparna, just as a design suggestion. It is best to refactor out the JDBC code and query into POJOs (Plain Old Java Object) helper classes for reuse by other Java code that might not necessarily be a Servlet. Servlets should really just handle the request and return the response, letting other helper class do the dirty work.

Mark
 
nilesh Katakkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also try committing the transaction

connection.commit()
 
Vrushank Joshi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aparna check ur date format in sql and in java.Date...
If both are same than write one method as below...
con.commit();
and than see the data in the database, i think this is the problem....

Regards,
Vrushank
 
R Bhatia
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Better put the query in a variable and execute like....

final String str = "INSERT INTO udetails......";
System.out.println(str);
st.executeUpdate(str);

And check what values are printed on your console.

Best of Luck,
R S
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"R S B"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
 
Ajith Anand
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Are you sure you are looking for the Exceptions at the right place ???
I would suggest you replace the doGet Exception Handler from


to


Just to make sure that the exceptions are not getting drowned elsewhere....
 
Maki Jav
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Closing your connection will commit your data to database table.

Maki Jav
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a JDBC problem and I should have moved it earlier. My apologies.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic