error oracle database connection?

Ads
 

error oracle database connection?

hi now i am trying to connect oracle database and also insert my data into table, but it's not working.. I created one user registration form. when i give values in the form, i want stored data in oracle table. my table name is logininfoclient_sla. this is my coding:

newuser_db.java

package com.sla;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.PreparedStatement;


import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * Servlet implementation class newuser_db
 */
public class newuser_db extends HttpServlet {
    private static final long serialVersionUID = 1L;
    PreparedStatement stmt=null;
    Connection con =null;
    ResultSet rs=null;


    /**
     * @see HttpServlet#HttpServlet()
     */
    public newuser_db() {
        super();
        // TODO Auto-generated constructor stub
    }
    @Override
    public void init() throws ServletException {
        // TODO Auto-generated method stub
        super.init();
        try
        {
            Class.forName("sun.Jdbc.Odbc.JdbcOdbcDriver");
        }
        catch (ClassNotFoundException ex)
        {
            ex.printStackTrace();
        }


        try
        {
            con =DriverManager.getConnection("Jdbc:odbc:servletdb","system","balaji");

        }
        catch(SQLException ex)
        {
            ex.printStackTrace();
        }



        // TODO Auto-generated method stub
    }

    @Override
    public void service(ServletRequest arg0, ServletResponse arg1)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        super.service(arg0, arg1);
        PrintWriter out=arg1.getWriter();
        String s1=arg0.getParameter("USERID");
        String s2=arg0.getParameter("FIRSTNAME");
        String s3=arg0.getParameter("LASTNAME");
        String s4=arg0.getParameter("EMAILID");
        String s5=arg0.getParameter("ORGNAME");
        String s6=arg0.getParameter("MOBILENO");
        String s7=arg0.getParameter("PHONENO");
        String s8=arg0.getParameter("PASSWORD");

        out.println("inserted");
        out.println(s1);




        out.println("inserted1");
        //String sql="insert into userdetails values(ka.nextval,"+s1+","+s2+","+s3+","+s4+","+s5+","+s6+","+s7+",56,'de',01-jan-98)";
        PreparedStatement stmt1;
        try {
            stmt1 = con.prepareStatement("insert into login_info_client_sla values(?,?,?,?,?,?,?,?)");
            stmt1.setString(1,s1);
            stmt1.setString(2,s2);
            stmt1.setString(3,s3);
            stmt1.setString(4,s4);
            stmt1.setString(5,s5);
            stmt1.setString(6,s6);
            stmt1.setString(7,s7);
            stmt1.setString(8,s8);


            //stmt1.executeUpdate();
            out.println("inserted2");
            stmt1.executeUpdate();
            out.println("inserted3");
        } catch (SQLException e1) {
            // TODO Auto-generated catch block
        out.println(e1);

        }


    }
    @Override
    public void destroy() {
        // TODO Auto-generated method stub
        super.destroy();
        try
        {
            if(stmt!=null)
                stmt.close();
            stmt=null;

        }
        catch (SQLException ex)
        {
            ex.printStackTrace();
        }
        try
        {
            if(con!=null)
                con.close();
            con=null;

        }
        catch (SQLException ex)
        {
            ex.printStackTrace();
        }
    }



    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

}

desing jsp page; newuser_reg.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="newuser_db" method="post">
<center><font size="15" color="agenda">SLA Customer Details</font></center>
<table><tr><td>E-Mail id* </td><td>:</td> <td> <input type="text" value="" name="EMAILID"></input></td></tr>
<tr><td>First Name* </td><td>:</td> <td> <input type="text" value="" name="FIRSTNAME"></input></td></tr>
<tr><td>Last Name* </td><td>:</td> <td> <input type="text" value="" name="LASTNAME"></input></td></tr>
<tr><td>Org Name* </td><td>:</td> <td> <input type="text" value="" name="ORGNAME"></input></td></tr>
<tr><td>Password* </td><td>:</td> <td> <input type="text" value="" name="PASSWORD"></input></td></tr>
<tr><td>Mobile No* </td><td>:</td> <td> <input type="text" value="" name="MOBILENO"></input></td></tr>
<tr><td>Phone* </td><td>:</td> <td> <input type="text" value="" name="PHONENO"></input></td></tr>
<tr><td></td><td><input type="submit" value="Add"/></td></tr>
</table>



</form>
</body>
</html>

please help me.....i am new for this application.....

View Answers

Ads









Related Tutorials/Questions & Answers:
how to connection jsp to oracle database connections in netbeans ide
how to connection jsp to oracle database connections in netbeans ide
Advertisements
error oracle database connection?
Oracle Database error - JDBC
error in uploading image from jsp to oracle 10g database
maximum limit of database connections have been reached.
maximum limit of database connections have been reached.
java with Oracle Database
Oracle Database connectivity probem
storing csv into oracle database
File insertion into oracle database
Spring and Oracle Database
error occured in oracle - JDBC
About connection database oracle to java
About connection database oracle to java
About connection database oracle to java
About connection database oracle to java
About connection database oracle to java
Oracle 9i database problem
Connecting Oracle database with struts - Struts
android connection to database oracle 10g
oracle insert statement error - JDBC
Oracle Database - Insert System Time
Java Connection to Oracle database
write excel file into the oracle database
jsp with database oracle
Database Connectivity Withe Oracle
oracle database backup using jsp
error at the oracle programm with jsp - JSP-Servlet
java.sql.SQLException: Network error IOException: No buffer space available (maximum connections reached?): connect
Java Barcode Program with Oracle database

Ads