• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

not able to insert values in ms access database

 
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Form.jsp



new2.jsp



my_ins : DNS Name
insert : Table Name





here is the code to inser values into ms access database, bt i m getting an exception here, can anyone help me in this...

exception


exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /new2.jsp at line 19

16:
17:
18: String sqlString= "Insert into insert(ID, u_name, u_post) values("+id1+",'"+nm1+"', '"+po1+"')";
19: int i=st.executeUpdate(sqlString);
20: %>
21: Record Add<%= i %><br>
22:

 
Ranch Hand
Posts: 72
Hibernate Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

Include the above mentioned code in try-catch block.
Because, the Class.forName() throws ClassNotFoundException and getConnection() method throws SQLException.
These are checked Exceptions.
So, you must include the above code in try-catch bock.
Writing java code in JSP is not a good practice!!
 
Marshal
Posts: 28009
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right. And when you catch the exception, write the stack trace to the logs so you can see what it is. Just saying "I got an exception" is not very useful. The information in the stack trace is what you need to see, including the text of the exception itself.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all, and i have convert my jsp to servlet and also added the try catch block, it's successfully running but no data is inserted into my access database, i m using ms access 2007...
here is my servlet:



 
Paul Clapham
Marshal
Posts: 28009
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is rather typical of MS Access. Apparently if you don't close the connection, or commit the transaction, you don't see the update happening.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have close the connections,

st.close();
db.close();

still i m not getting the values into my database..
 
Paul Clapham
Marshal
Posts: 28009
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are looking in the table named "insert", are you not? (I'm surprised that using a table named "insert" doesn't cause an SQL syntax error.)

Also, what is the value of that "i" variable?
 
Gopakumar Naryanan
Ranch Hand
Posts: 72
Hibernate Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, sometimes this happens with MS Access.
Just checkout your DSN. Reopen MS Access ,once you execute the program.
(By the way don't use the SQL key words as table name.. it may cause some ambiguity.. rename the table if you don't mind.)
It should work.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i got it, it's probably my database problem, because in my another database values are inserting.

Thank you all...
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i more problem i m facing, i have inserted data into database, bt while fetching the same data it displays nothing on the page, here is my servlet to fetch and display data, please help me in this also,




my login.jsp page is simply a form having two text fields and one submit....
 
Gopakumar Naryanan
Ranch Hand
Posts: 72
Hibernate Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had noticed the following:

DSN name is different compared to insertion & this one.
Didn't find HTML, BODY tags.
You got the data , userid.. didn't set in any scope.. how can the jsp gets these values?
Again, writing html code in java code is not a good practice.. try practicing EL with JSP.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




 
He's giving us the slip! Quick! Grab this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic