This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

A servlet code written to add details in database but not happening?  RSS feed

 
Ranch Hand
Posts: 1083
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



is there something wrong in this code??? I am not able to see it out
 
Author and ninkuma
Marshal
Posts: 66789
168
IntelliJ IDE Java jQuery Mac Mac OS X
 
Vishal Hegde
Ranch Hand
Posts: 1083
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

I have a Jsp page having add hyperlink.Once clicked it redirects to a JSP page where i input name email address and all and once clicked on submit button the form action attribute is set to go to prepared_statement_query servlet to add the values in the database...

I was hoping that select statement in SQL query will display new values i inputted in the jsp page.but no luck the table remains the same and is not added with any new information
 
Greenhorn
Posts: 20
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Did you check Container's log file.

Suggestion :
Try printing the values you receive from JSP.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vishal Hegde wrote:Hi Bear,

I have a Jsp page having add hyperlink.Once clicked it redirects to a JSP page where i input name email address and all and once clicked on submit button the form action attribute is set to go to prepared_statement_query servlet to add the values in the database...

I was hoping that select statement in SQL query will display new values i inputted in the jsp page.but no luck the table remains the same and is not added with any new information



did you create the database in mysql and the table,
if you did not the you need to do that first.
Also debug it using debugger and see what is happening
is it running fine or is it raising some exception.
let me know
 
Vishal Hegde
Ranch Hand
Posts: 1083
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

reddy ajay wrote:

Vishal Hegde wrote:Hi Bear,

I have a Jsp page having add hyperlink.Once clicked it redirects to a JSP page where i input name email address and all and once clicked on submit button the form action attribute is set to go to prepared_statement_query servlet to add the values in the database...

I was hoping that select statement in SQL query will display new values i inputted in the jsp page.but no luck the table remains the same and is not added with any new information



did you create the database in mysql and the table,
if you did not the you need to do that first.
Also debug it using debugger and see what is happening
is it running fine or is it raising some exception.
let me know




Hi Ajay,

Offcourse i Created the table did you read the code for connecting my database to the table?
 
Vishal Hegde
Ranch Hand
Posts: 1083
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Anshuman Chakraborty wrote:Hi,

Did you check Container's log file.

Suggestion :
Try printing the values you receive from JSP.




Where do i check the Log files??? Yes i did tried printing those those are successfully done
 
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try loading the JDBC driver.
 
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vishal Hegde wrote:
Offcourse i Created the table did you read the code for connecting my database to the table?



There is no 'of course' about it. Nothing in the code you posted creates the database or the table 'customer' or sets up the data source 'VirtualClassRoom' linking JDBC with ODBC.

There are some other weaknesses -

1) you are relying on a particular table column order which is not a good idea; you should specify the column names when using an insert.
2) your exception handling is very very poor.
3) there is no explicit commit() and there is no indication as to whether or not you are using auto-commit (I have not use the JDBC-ODBC bridge for a long time and I can't remember whether or not auto-commit matters).

As has been said - find the log files and see what they say.
 
Ranch Hand
Posts: 54
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishal,
Load the JDBC driver first before coonnecting to database. You should have got "No suitable driver" as error message since you have not loaded the driver.

 
Vishal Hegde
Ranch Hand
Posts: 1083
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

James Sabre wrote:

Vishal Hegde wrote:
Offcourse i Created the table did you read the code for connecting my database to the table?



There is no 'of course' about it. Nothing in the code you posted creates the database or the table 'customer' or sets up the data source 'VirtualClassRoom' linking JDBC with ODBC.

There are some other weaknesses -

1) you are relying on a particular table column order which is not a good idea; you should specify the column names when using an insert.
2) your exception handling is very very poor.
3) there is no explicit commit() and there is no indication as to whether or not you are using auto-commit (I have not use the JDBC-ODBC bridge for a long time and I can't remember whether or not auto-commit matters).

As has been said - find the log files and see what they say.



Hi James,

I have created a Customer table using select statment in MS -SQL did database connectivity going to control panel->Administratitve tools-->DataSourcesODBC) And added a user DSN named "VirtualClassRoom"

Also created a VirtualClassRoom database in MSSQL and added a table customer on it added one column to test for login authentication and its working fine... and now for insertin the value i am facing this problem
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vishal Hegde wrote:
I have created a Customer table using select statment in MS -SQL did database connectivity going to control panel->Administratitve tools-->DataSourcesODBC) And added a user DSN named "VirtualClassRoom"

Also created a VirtualClassRoom database in MSSQL and added a table customer on it added one column to test for login authentication and its working fine... and now for insertin the value i am facing this problem



Since it's not obvious to me from the above that you did, did you add columns for user name, password, full name and login type etc? Also, did you check the servlet logs to see what they say? The logs should tell you exactly what the problem is.
 
Vishal Hegde
Ranch Hand
Posts: 1083
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

James Sabre wrote:

Vishal Hegde wrote:
I have created a Customer table using select statment in MS -SQL did database connectivity going to control panel->Administratitve tools-->DataSourcesODBC) And added a user DSN named "VirtualClassRoom"

Also created a VirtualClassRoom database in MSSQL and added a table customer on it added one column to test for login authentication and its working fine... and now for insertin the value i am facing this problem



Since it's not obvious to me from the above that you did, did you add columns for user name, password, full name and login type etc? Also, did you check the servlet logs to see what they say? The logs should tell you exactly what the problem is.



Yes i did those ,where should i check the logs? I am using netbeans?
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google is wonderful - http://blogs.oracle.com/NetBeansSupport/entry/tomcat_log_files
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!