error oracle database connection?

Ads

 
 
 

Share on Google+Share on Google+

balaji
error oracle database connection?
0 Answer(s)      5 years and 8 months ago
Posted in : JSP-Servlet

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

Ads
View Answers
Ads









Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads