Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Not able to inser data in mysql database

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Not able to inser data in mysql database

    I have written a small program to insert data, but I am not able to do that, my program runs till Out.println "4444" and then stops please help
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;

    public class BichhuServlet extends HttpServlet

    {
    public void BichhuServlet(){}
    public void init(ServletConfig config) throws ServletException

    {
    super.init(config);
    }
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

    {
    doPost(request, response);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

    {
    ServletOutputStream out=response.getOutputStream();

    String info=request.getParameter("information");
    //String iName=request.getParameter("infoName");
    //String iEmail=request.getParameter("infoEmail");
    //String iTel=request.getParameter("infoTel");
    //String iFax=request.getParameter("infoFax");
    String iSubject=request.getParameter("infoSubject");
    //String company=request.getParameter("comp");

    Connection con=null;

    String url = "jdbc:mysql://localhost/croreco_india123";
    out.println("1");
    try {
    Class.forName("org.gjt.mm.mysql.Driver").newInstan ce();
    out.println("2");
    }
    catch (Exception E) {
    E.printStackTrace();
    }
    out.println("3");
    try { out.println("4444");
    Statement stmt;

    con = DriverManager.getConnection(url, "croreco_vineet", "14parasmaj");
    out.println("5");
    stmt = con.createStatement();
    out.println("6");
    stmt.executeUpdate("INSERT INTO ContactUsB (Subject, InfoRequired)VALUES('"+iSubject+"','"+info+"')");
    out.println("data");
    stmt.close();
    con.close();
    }
    catch(SQLException ex) {
    System.err.println("==> SQLException: ");
    while (ex != null) {
    System.err.println("Message: " + ex.getMessage ());
    System.err.println("SQLState: " + ex.getSQLState ());
    System.err.println("ErrorCode: " + ex.getErrorCode ());
    ex = ex.getNextException();
    System.out.println("");
    }
    }


    out.close();


    }
    public String getServletInfo()
    {
    return "BichhuServlet Information";
    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Not able to inser data in mysql database

    Are there any errors (this is a servlet, so does the errors stream of the container show any errors)?

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Not able to inser data in mysql database

    Quote Originally Posted by copeg View Post
    Are there any errors (this is a servlet, so does the errors stream of the container show any errors)?

    Thanks of showing interest in helping
    No the srvlet runs upto line where I have put 4444 shows output like
    1
    2
    3
    4444





    then blank thats all no other error

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Not able to inser data in mysql database

    No the srvlet runs upto line where I have put 4444 shows output like
    Sounds like you are referring to the servlet output - any exceptions thrown and the output goes to stderr which is the servlet container (eg server) stderr which you will not see in the Servlet output. Look at that stream, or write something to the Servlet PrintStream (out) to debug and verify no exceptions are being caught.

  5. #5
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Not able to inser data in mysql database

    ok thanks a lot

Similar Threads

  1. Inserting data from ObservableList to MySQL database
    By TiJuan in forum JDBC & Databases
    Replies: 0
    Last Post: June 2nd, 2013, 11:16 AM
  2. Re: Import Data from Excel to Mysql Database
    By piya in forum JDBC & Databases
    Replies: 3
    Last Post: May 10th, 2013, 06:06 AM
  3. Import Data from Excel to Mysql Database
    By StarRocks in forum JDBC & Databases
    Replies: 2
    Last Post: August 29th, 2012, 11:40 PM
  4. [SOLVED] Passing data to a MySQL database
    By JDyson in forum JDBC & Databases
    Replies: 1
    Last Post: December 1st, 2010, 01:31 PM
  5. [SOLVED] Get Data From Database MySQL using ComboBox
    By Simple in forum Java Theory & Questions
    Replies: 2
    Last Post: June 4th, 2010, 02:45 AM

Tags for this Thread