• 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

insertion into the database

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sir
the code below is to enter the items in the database but it is giving the error .......of null.................

<!-- JAI SHRI RAM -->
<%@ page import="java.sql.*" %>
<html>
<head><title>JAI SHRI RAM</title></head>
<body>

<%

String url = "jdbc dbc:lala" ;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(url,"","");
Statement st = conn.createStatement();
for(int i=1 ; i<=13 ; i++)
{
String skill_type = request.getParameter("skill_type"+i);
String skill_name = request.getParameter("skill_name"+i);
String version = request.getParameter("version"+i);
String lastused = request.getParameter("last_used"+i);
int last_used = Integer.parseInt(lastused);
String proficiency_level = request.getParameter("proficiency_level"+i);
String expinyears = request.getParameter("exp_in_years"+i);
int exp_in_years = Integer.parseInt(expinyears);
String expinmonths = request.getParameter("exp_in_months"+i);
int exp_in_months = Integer.parseInt(expinmonths);


String query = "insert into skills values(1 , '" + skill_type + "' , '" + skill_name + "', '" + version + "', 1 , '" + proficiency_level + "', 1 ,1)";
st.executeUpdate(query);
}
out.println("JAI SHRI RAM ,,,,,,,, transcation is over");

%>

</body>
</html>

i m using MS ACCESS
please tell me the problem

thank you
gaurav
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it is giving the error .......of null.................

What is giving the error?

Are you seeing a stack trace in your browser?
If so, is there a "ROOT CAUSE" section?
If not, what's in your server's logs?

There are several things in this code that could cause a NullPointerException (NPE).

Start by putting an "out.println" statement under each call to getParameter to see if you are getting the values that you are expecting from the form.


If not, you will see a NullPointerException when you try to convert the value to an int.

Also, print the value of your SQL query to the page.
Do you already know that you are successfully connecting to the database?

There are a lot of debugging steps that you should go through before asking for help. If you start by posting to a forum, you are selling yourself short.

If you do finally give up and want to look to a forum for help, make it as easy as possible for people to help you. Use the UBB Code tag to wrap the code that you post so your indenting will be preserved. This makes it much easier to us to read it. Post the actual error message instead of typing
"it is giving the error .......of null". Also, state the steps you have gone through so we don't spend time doing the same thing. IE: let us know if you've already connected to the database with the same DSN, etc..
[ February 26, 2005: Message edited by: Ben Souther ]
 
Sheriff
Posts: 67746
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
What Ben said... and, moved to the JDBC forum since this really has nothing to do with JSP.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic