Hi everyone, I need help in my school project which requires me to send data from a mobile application to a database table. The inputs for the table data is through textfield and when i press the submit button, it will send the input fields into the database table. Will be appreciated if anyone is there to help me.. thanks

Here are my current codes, I am only able to retreive data from the table but unable to send over.

Client

package web;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.HttpConnection;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;

public class EnrollmentClient extends MIDlet implements CommandListener {

    Display display;
    private boolean commandAvailable;
    CommandThread commandThread;
    Form registerForm;
    Form inputForm;
    Form outputForm;
    TextField idNum;
    TextField name;
    TextField nirc;
    TextField contact;
    TextField email;
    TextField l1r4;
    StringItem appResults;
    Command cmdBack;
    Command cmdQuit;
    Command cmdSend;
    Command cmdSelect;
    Command cmdSubmit;
    private static final String send =
            "jdbc:mysql://localhost:3306/student_info?"
            + "user=root&password=password";
    private static final String retrieve =
            "http://localhost:8084/EnrollmentServlet/EnrollmentServlet"
            + "?nirc=";
    List mainMenu;
    String[] options = {"Apply for Courses", "Check Application Status", "Exit"};

    public EnrollmentClient() {

        mainMenu = new List("Main Menu", Choice.IMPLICIT, options, null);
        mainMenu.setCommandListener(this);
        cmdSelect = new Command("Select", Command.SCREEN, 1);
        mainMenu.addCommand(cmdSelect);


        display = Display.getDisplay(this);

        registerForm = new Form("Registration Form");
        name = new TextField("Name:", null, 25, TextField.ANY);
        nirc = new TextField("NIRC:\n", null, 9, TextField.ANY);
        contact = new TextField("Contact:\n", null, 12, TextField.PHONENUMBER);
        email = new TextField("Email:\n", null, 20, TextField.EMAILADDR);
        l1r4 = new TextField("L1R4:\n", null, 9, TextField.NUMERIC);



        registerForm.append(name);
        registerForm.append(nirc);
        registerForm.append(contact);
        registerForm.append(email);
        registerForm.append(l1r4);

        cmdSubmit = new Command("Submit", Command.SCREEN, 1);
        registerForm.addCommand(cmdSubmit);
        registerForm.setCommandListener(this);


        inputForm = new Form("Check Application Status");
        idNum = new TextField("NIRC Number: ", null, 9, TextField.ANY);
        inputForm.append(idNum);
        cmdSend = new Command("Send", Command.SCREEN, 1);
        cmdQuit = new Command("Quit", Command.EXIT, 1);
        inputForm.addCommand(cmdSend);
        inputForm.addCommand(cmdQuit);
        inputForm.setCommandListener(this);

        outputForm = new Form("Application Status");
        appResults = new StringItem(null, null);
        outputForm.append(appResults);
        cmdBack = new Command("Back", Command.BACK, 1);
        outputForm.addCommand(cmdBack);
        outputForm.addCommand(cmdQuit);
        outputForm.setCommandListener(this);

        commandAvailable = false;
        commandThread = new CommandThread(this);
        commandThread.start();

    }

    public void startApp() {

        display.setCurrent(mainMenu);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {

        switch (mainMenu.getSelectedIndex()) {
            case 0:
//Go work on
                display.setCurrent(registerForm);
                break;

            case 1:
                display.setCurrent(inputForm);

                break;

            case 2:
                destroyApp(false);
                notifyDestroyed();
                break;

        }
        if (c == cmdQuit) {
            display.setCurrent(mainMenu);
        } else if (c == cmdSend) {
            synchronized (this) {
                commandAvailable = true;
                notify();
            }
        } else if (c == cmdSubmit) {
        }
        /*
        if (c == cmdExit) {
        destroyApp(false);
        notifyDestroyed();
        } else if (c == cmdBack) {
        idNum.setString(null);
        display.setCurrent(inputForm);
        appResults.setText(null);
        } else if (c == cmdOK) {
        synchronized (this) {
        commandAvailable = true;
        notify();
        }
        }
         */
    }

    class CommandThread extends Thread {

        MIDlet parent;
        boolean exit = false;

        public CommandThread(MIDlet parent) {
            this.parent = parent;
        }

        public void run() {
            while (true) {
                synchronized (parent) {
                    while (!commandAvailable) {
                        try {
                            parent.wait();
                        } catch (InterruptedException e) {
                        }
                    }
                    commandAvailable = false;
                }

                getAppStatus();
            }
        }

        public void getAppStatus() {
            HttpConnection conn = null;
            InputStream is = null;
            OutputStream os = null;
            byte[] receivedData = null;
            try {
                StringBuffer sb = new StringBuffer(retrieve);
                sb.append(idNum.getString());
                System.out.println("String sent: " + sb.toString());
                conn =
                        (HttpConnection) Connector.open(sb.toString());
                conn.setRequestMethod(HttpConnection.GET);
                conn.setRequestProperty("User-Agent",
                        "Profile/MIDP-1.0 Configuration/CLDC-1.0");
                conn.setRequestProperty("Content-type",
                        "application/x-www-form-urlencoded");
                is = conn.openInputStream();
                String contentType = conn.getType();
                int len = (int) conn.getLength();
                if (len > 0) {
                    receivedData = new byte[len];
                    int nb = is.read(receivedData);
                } else {
                    receivedData = new byte[1024];
                    int ch;
                    len = 0;
                    while ((ch = is.read()) != -1) {
                        receivedData[len++] = (byte) ch;
                    }
                }
                appResults.setText(new String(receivedData, 0, len));
                display.setCurrent(outputForm);
            } catch (IOException e) {
                System.out.println(e.getMessage());
                e.printStackTrace();
            } finally {
                try {
                    if (is != null) {
                        is.close();
                    }

                    if (os != null) {
                        os.close();
                    }

                    if (conn != null) {
                        conn.close();
                    }
                } catch (IOException e) {
                }
            }
        }
    }
}

Servlet

import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

import java.sql.*;

public class EnrollmentServlet extends HttpServlet {

    static final String dbURL = "jdbc:mysql://localhost:3306/student_info?"
            + "user=root&password=password";

    public void doSend(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        Connection conn = null;

        response.setContentType("text/plain");
        PrintWriter outResponse = response.getWriter();

        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new ServletException("Unable to load JDBC driver");
        }

        try {



            String userInputname = request.getParameter("full_name");
            String userInputNIRC = request.getParameter("nirc");
            String userInputcontact = request.getParameter("contact");
            String userInputemail = request.getParameter("email");
            String userInputl1r4 = request.getParameter("l1r4");

            conn = DriverManager.getConnection(dbURL);
            PreparedStatement ps = conn.prepareStatement("INSERT INTO info VALUES (?,?,?,?,?)");
          
            ps.setString(2, userInputname);
            ps.setString(3, userInputNIRC);
            ps.setString(4, userInputcontact);
            ps.setString(5, userInputemail);
            ps.setString(6, userInputl1r4);
     
            ps.execute();

            conn.close();
          
        } catch (SQLException e) {
            throw new ServletException("SQL call failed");
        } catch (Exception e) {
            throw new ServletException(e.getMessage());
        } finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {
                    throw new ServletException("connection close failed");
                }
            }
        }
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        Connection conn = null;

        response.setContentType("text/plain");
        PrintWriter outResponse = response.getWriter();

        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new ServletException("Unable to load JDBC driver");
        }

        try {

            String NIRC = request.getParameter("nirc");
            System.out.println("NIRC = " + NIRC);
            conn = DriverManager.getConnection(dbURL);

            Statement stmt = conn.createStatement();

            String query = "SELECT * "
                    + "FROM info " + "WHERE nirc = '"
                    + NIRC + "'";



            ResultSet rs = stmt.executeQuery(query);
            if (rs.next()) {
                outResponse.println(rs.getString(2));
                outResponse.println(rs.getString(3));
                outResponse.println(rs.getString(7));

            } else {
                outResponse.println("Record Not Found");
            }
            conn.close();
        } catch (SQLException e) {
            throw new ServletException("SQL call failed");
        } catch (Exception e) {
            throw new ServletException(e.getMessage());
        } finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {
                    throw new ServletException("connection close failed");
                }
            }
        }
    }
}

And yea, im using netbeans to do it..

Any help here? Need help urgently thanks

Hi

Glad to meet a netbeans fan too.

These problems leap to my eye:

PreparedStatement ps = conn.prepareStatement("INSERT INTO info VALUES (?,?,?,?,?)");
ps.setString(2, userInputname);
ps.setString(3, userInputNIRC);
ps.setString(4, userInputcontact);
ps.setString(5, userInputemail);
ps.setString(6, userInputl1r4);
ps.execute();

-- The first ? is numbered 1, so the setters should be called with:

ps.setString([B]1[/B], userInputname);
ps.setString([B]2[/B], userInputNIRC);
ps.setString([B]3[/B], userInputcontact);
ps.setString([B]4[/B], userInputemail);
ps.setString([B]5[/B], userInputl1r4);

Also I am missing commit statement. You can attach it to your insert statement :

conn.prepareStatement("INSERT INTO info VALUES (?,?,?,?,?)[B] ; commit ;[/B] ");

Attention: where to place the commit depends on your overall transaction. So it might be not a good idea to make a commit after every insert-statement. However, one should never forget the commit (or rollback) after insert, update, delete.

It is always saver to list the columns (example: a, b...) you want to insert values:

conn.prepareStatement("INSERT INTO info [B](a,b,c,d,e)[/B] VALUES (?,?,?,?,?) ; commit ; ");

>>> Here are my current codes, I am only able to retreive data from the table but unable to send over.

Btw, is there any error message / exception ?
Because of wrong "ps.setString(6, userInputl1r4);" there should arise sql exception.

-- tesu

hmm... how about my client side? how do i trigger my submit button to perform this sending action?

edited my servlet code...

import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

import java.sql.*;

public class EnrollmentServlet extends HttpServlet {

    static final String dbURL = "jdbc:mysql://localhost:3306/student_info?"
            + "user=root&password=password";
    Connection conn = null;

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


        response.setContentType("text/plain");
        PrintWriter outResponse = response.getWriter();



        try {

            Class.forName("com.mysql.jdbc.Driver");

            String userInputname = request.getParameter("name");
            String userInputNIRC = request.getParameter("nirc");
            String userInputcontact = request.getParameter("contact");
            String userInputemail = request.getParameter("email");
            String userInputl1r4 = request.getParameter("l1r4");

            conn = DriverManager.getConnection(dbURL);
            PreparedStatement pstmt = conn.prepareStatement("insert into info (full_name,nirc,contact,email,l1r4,results) values(?,?,?,?,?,?);commit;");

        
            pstmt.setString(1, userInputname);
            pstmt.setString(2, userInputNIRC);
            pstmt.setString(3, userInputcontact);
            pstmt.setString(4, userInputemail);
            pstmt.setString(5, userInputl1r4);
            pstmt.setString(6, "Under Moderation");

            pstmt.executeUpdate();
            pstmt.close();
            /*    pstmt.executeUpdate("INSERT INTO info VALUES "
            + "('" + userInputname + "',"
            + "'" + userInputNIRC + "','"
            + userInputcontact + "','"
            + userInputemail + "','"
            + userInputl1r4 + "') ");
             */


        } catch (SQLException e) {
            throw new ServletException("SQL call failed");
        } catch (Exception e) {
            throw new ServletException(e.getMessage());
        } finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {
                    throw new ServletException("connection close failed");
                }
            }
        }
    }

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

        response.setContentType("text/plain");
        PrintWriter outResponse = response.getWriter();

        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new ServletException("Unable to load JDBC driver");
        }

        try {

            String NIRC = request.getParameter("nirc");
            System.out.println("NIRC = " + NIRC);
            conn = DriverManager.getConnection(dbURL);

            Statement stmt = conn.createStatement();

            String query = "SELECT * "
                    + "FROM info " + "WHERE nirc = '"
                    + NIRC + "'";



            ResultSet rs = stmt.executeQuery(query);
            if (rs.next()) {
                outResponse.println(rs.getString(1));
                outResponse.println(rs.getString(2));
                outResponse.println(rs.getString(6));

            } else {
                outResponse.println("Record Not Found");
            }
            conn.close();
        } catch (SQLException e) {
            throw new ServletException("SQL call failed");
        } catch (Exception e) {
            throw new ServletException(e.getMessage());
        } finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {
                    throw new ServletException("connection close failed");
                }
            }
        }
    }
}

Well, that depends on where doSend(..) is ececuted from.

I also hope that this

"jdbc:mysql://localhost:3306/student_info?"
+ "user=root&password=password";

is syntactically correct and right user and password be set. Eventually there must be a
space here: + " user=...

(I stopped doing such stuff on MySQL a couple of years ago)

I have checked connection string. Yours is ok, no space requiered. Also your imports (import java.sql.*) are ok.

Question: did you also register your driver, e.g. that way:
Class.forName("com.mysql.jdbc.Driver").newInstance();
(on line 78 of your code you might add .newInstance())

-- tesu

hmm, dont really get the idea, so how do i set the doSend to execute the servlet? Sorry i didn't learnt this at all in school, the teacher just throw us the work and ask us to do ..

and for the newInstance(); , i tried adding but there is an error..

-shock8

>>> and for the newInstance(); , i tried adding but there is an error..

How did you figured out that an error occurred? Are there really error messages? If so, what do you think of posting them?

I went through your code again, what I am missing are:

1. There is no init() method, servlets executes init() first. If you add init(), don't forget to call there super.init(..) first !

2. Your doSend(..) is nowhere called. Maybe you put it in the doPost() method which I also missing in your code. It depends on where your servlet executes (server or web site) whether you need doGet() or doPost() method.

Assuming you need doPost() for your servlet is running on website, I would simply rename doSend(its parameter list is ok) into doPost(...) (instead of creating a new doPost() where doSend() must be called from.)

When you write out your html form, there must also be a call for your servlet what is done by form action method "POST".

Well, you stated that you were already able to retrieve data from your table ("I am only able to retreive data from the table") so I think that you must have already known above stuff I am talking of.

Any way, try something out of that stuff, especially introduce both doPost() in your java code and form action method "post" on your html form.

-- tesu

thanks for your reply, just edited my java codings

Client

package web;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.HttpConnection;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;

public class EnrollmentClient extends MIDlet implements CommandListener {

    Display display;
    private boolean commandAvailable;
    CommandThread commandThread;
    Form registerForm;
    Form inputForm;
    Form outputForm;
    TextField idNum;
    TextField name;
    TextField nirc;
    TextField contact;
    TextField email;
    TextField l1r4;
    StringItem appResults;
    Command cmdBack;
    Command cmdQuit;
    Command cmdSend;
    Command cmdSelect;
    Command cmdSubmit;
    String mode;
    private static final String retrieve =
            "http://localhost:8084/EnrollmentServlet/EnrollmentServlet"
            + "?mode=";
    List mainMenu;
    String[] options = {"Apply for Courses", "Check Application Status", "Exit"};

    public EnrollmentClient() {

        mainMenu = new List("Main Menu", Choice.IMPLICIT, options, null);
        mainMenu.setCommandListener(this);
        cmdSelect = new Command("Select", Command.SCREEN, 1);
        mainMenu.addCommand(cmdSelect);


        display = Display.getDisplay(this);

        registerForm = new Form("Registration Form");
        name = new TextField("Name:", null, 25, TextField.ANY);
        nirc = new TextField("NIRC:\n", null, 9, TextField.ANY);
        contact = new TextField("Contact:\n", null, 12, TextField.PHONENUMBER);
        email = new TextField("Email:\n", null, 20, TextField.EMAILADDR);
        l1r4 = new TextField("L1R4:\n", null, 9, TextField.NUMERIC);



        registerForm.append(name);
        registerForm.append(nirc);
        registerForm.append(contact);
        registerForm.append(email);
        registerForm.append(l1r4);

        cmdSubmit = new Command("Submit", Command.SCREEN, 1);
        registerForm.addCommand(cmdSubmit);
        registerForm.setCommandListener(this);


        inputForm = new Form("Check Application Status");
        idNum = new TextField("NIRC Number: ", null, 9, TextField.ANY);
        inputForm.append(idNum);
        cmdSend = new Command("Send", Command.SCREEN, 1);
        cmdQuit = new Command("Quit", Command.EXIT, 1);
        inputForm.addCommand(cmdSend);
        inputForm.addCommand(cmdQuit);
        inputForm.setCommandListener(this);

        outputForm = new Form("Application Status");
        appResults = new StringItem(null, null);
        outputForm.append(appResults);
        cmdBack = new Command("Back", Command.BACK, 1);
        outputForm.addCommand(cmdBack);
        outputForm.addCommand(cmdQuit);
        outputForm.setCommandListener(this);

        commandAvailable = false;
        commandThread = new CommandThread(this);
        commandThread.start();

    }

    public void startApp() {

        display.setCurrent(mainMenu);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {

        switch (mainMenu.getSelectedIndex()) {
            case 0:
//Go work on
                display.setCurrent(registerForm);

                break;

            case 1:
                display.setCurrent(inputForm);


                break;

            case 2:
                destroyApp(false);
                notifyDestroyed();
                break;

        }
        if (c == cmdQuit) {
            display.setCurrent(mainMenu);
        } else if (c == cmdSend) {
            mode = "query";
            synchronized (this) {
                commandAvailable = true;
                notify();
            }
        } else if (c == cmdSubmit) {
            mode = "save";
            synchronized (this) {
                commandAvailable = true;
                notify();
            }
        }
        /*
        if (c == cmdExit) {
        destroyApp(false);
        notifyDestroyed();
        } else if (c == cmdBack) {
        idNum.setString(null);
        display.setCurrent(inputForm);
        appResults.setText(null);
        } else if (c == cmdOK) {
        synchronized (this) {
        commandAvailable = true;
        notify();
        }
        }
         */
    }

    class CommandThread extends Thread {

        MIDlet parent;
        boolean exit = false;

        public CommandThread(MIDlet parent) {
            this.parent = parent;
        }

        public void run() {
            while (true) {
                synchronized (parent) {
                    while (!commandAvailable) {
                        try {
                            parent.wait();
                        } catch (InterruptedException e) {
                        }
                    }
                    commandAvailable = false;
                }

                getAppStatus();
            }
        }

        public void getAppStatus() {
            HttpConnection conn = null;
            InputStream is = null;
            OutputStream os = null;
            byte[] receivedData = null;
            try {

                StringBuffer sb = new StringBuffer(retrieve + mode);
                if (mode.equals("save")) {
                    sb.append("&full_name= " + name.getString()
                            + "&nirc=" + nirc.getString()
                            + "&contact=" + contact.getString()
                            + "&email=" + email.getString()
                            + "&l1r4=" + l1r4.getString());


                } else if (mode.equals("query")) {
                    sb.append("&nirc=" + idNum.getString());
                }

                conn =
                        (HttpConnection) Connector.open(sb.toString());
                conn.setRequestMethod(HttpConnection.GET);
                conn.setRequestProperty("User-Agent",
                        "Profile/MIDP-1.0 Configuration/CLDC-1.0");
                conn.setRequestProperty("Content-type",
                        "application/x-www-form-urlencoded");
                is = conn.openInputStream();
                String contentType = conn.getType();
                int len = (int) conn.getLength();
                if (len > 0) {
                    receivedData = new byte[len];
                    int nb = is.read(receivedData);
                } else {
                    receivedData = new byte[1024];
                    int ch;
                    len = 0;
                    while ((ch = is.read()) != -1) {
                        receivedData[len++] = (byte) ch;
                    }
                }
                appResults.setText(new String(receivedData, 0, len));
                display.setCurrent(outputForm);
            } catch (IOException e) {
                System.out.println(e.getMessage());
                e.printStackTrace();
            } finally {
                try {
                    if (is != null) {
                        is.close();
                    }

                    if (os != null) {
                        os.close();
                    }

                    if (conn != null) {
                        conn.close();
                    }
                } catch (IOException e) {
                }
            }
        }
    }
}

Servlet

import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

import java.sql.*;

public class EnrollmentServlet extends HttpServlet {

    static final String dbURL = "jdbc:mysql://localhost:3306/student_info?"
            + "user=root&password=password";
    Connection conn = null;

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

        response.setContentType("text/plain");
        PrintWriter outResponse = response.getWriter();

        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new ServletException("Unable to load JDBC driver");
        }

        try {

            String mode = request.getParameter("mode");
            if (mode.equals("save")) {

                conn = DriverManager.getConnection(dbURL);

                String userInputname = request.getParameter("full_name");
                String userInputnirc = request.getParameter("nirc");
                String userInputcontact = request.getParameter("contact");
                String userInputemail = request.getParameter("email");
                String userInputl1r4 = request.getParameter("l1r4");


                System.out.println("Name = " + userInputname);
                System.out.println("NIRC = " + userInputnirc);
                System.out.println("Contact = " + userInputcontact);
                System.out.println("Email = " + userInputemail);
                System.out.println("L1R4 = " + userInputl1r4);

                Statement stmt = conn.createStatement();

                String send = ("INSERT INTO info(full_name,nirc,contact,email,l1r4,results) VALUES ('" + userInputname + "','" + userInputnirc + "','" + userInputcontact + "','" + userInputemail + "','" + userInputl1r4 + "') ");

                stmt.executeUpdate(send);

                conn.close();
                /*

                PreparedStatement pstmt = conn.prepareStatement("INSERT INFO info (full_name,nirc,contact,email,l1r4,results) values(?,?,?,?,?,?);");


                pstmt.setString(1, userInputname);
                pstmt.setString(2, userInputnirc);
                pstmt.setString(3, userInputcontact);
                pstmt.setString(4, userInputemail);
                pstmt.setString(5, userInputl1r4);
                pstmt.setString(6, "Under Moderation");



                pstmt.executeUpdate();
                pstmt.close();
                 */
            } else if (mode.equals("query")) {
                String NIRC = request.getParameter("nirc");
                System.out.println("NIRC = " + NIRC);
                conn = DriverManager.getConnection(dbURL);

                Statement stmt = conn.createStatement();

                String query = "SELECT * "
                        + "FROM info " + "WHERE nirc = '"
                        + NIRC + "'";

                ResultSet rs = stmt.executeQuery(query);
                if (rs.next()) {
                    outResponse.println(rs.getString(1));
                    outResponse.println(rs.getString(2));
                    outResponse.println(rs.getString(6));

                } else {
                    outResponse.println("Record Not Found");
                }
                conn.close();
            }
        } catch (SQLException e) {
            throw new ServletException("SQL call failed");
        } catch (Exception e) {
            throw new ServletException(e.getMessage());
        } finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {
                    throw new ServletException("connection close failed");
                }
            }
        }
    }
}

currently the problems i am i having is with the insert instance , String send = ("INSERT INTO info(full_name,nirc,contact,email,l1r4,results) VALUES ('" + userInputname + "','" + userInputnirc + "','" + userInputcontact + "','" + userInputemail + "','" + userInputl1r4 + "') ");
, this doesn't seems to send my coding to my database

any help here?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.