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!!
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.
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:
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.
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....
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.