• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

MS Access data insert problem

 
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 ]
 
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.
 
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
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • 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
 
ranger
Posts: 17346
11
Mac IntelliJ IDE 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
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also try committing the transaction

connection.commit()
 
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
 
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
Posts: 17346
11
Mac IntelliJ IDE 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
 
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....
 
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Closing your connection will commit your data to database table.

Maki Jav
 
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.
 
We can fix it! We just need some baling wire, some WD-40, a bit of duct tape and this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic