• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



is there something wrong in this code??? I am not able to see it out
 
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TellTheDetails
 
Vishal Hegde
Ranch Hand
Posts: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try loading the JDBC driver.
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Google is wonderful - http://blogs.oracle.com/NetBeansSupport/entry/tomcat_log_files
 
They weren't very bright, but they were very, very big. Ad contrast:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic