ResultSet into ResultSet Mysql servlets

Hi!
I have a problem with this code:
while (result.next())
dgenre=statement.executeQuery("select value from table_genre where id_1=1 and id_2=3");                              
if (dgenre.next())
out.println("hello");
dgenre.close();     
println("<br> La dist�ncia �s:" + dist);
i = i+1;
out.println(i);
even if i should be 10, becouse "result" have ten results, the program only do once the bucle.
Is possible that Mysqd doens't allow 1 query into another?
Thanx!

MySQL does not support subselects but that isn't what you're doing, so it shouldn't be an issue. The question is, what are you doing? You're running the exact same query:dgenre=statement.executeQuery("select value from table_genre where id_1=1 and id_2=3"); as many times as this: while (result.next()) {
}is true, which doesn't appear to serve any purpose.

Similar Messages

  • Is it possible to insert data into a MySQL database with Java?

    Hello everyone!
    I would like to know, if it's possible to insert data into a MySQL database, with a JFrame inside a servlet?
    When the JFrame is first created it calls this method:
         * Connects the servlet with the MySQL database.
        private void connect(){
            try{
                Class.forName("com.mysql.jdbc.Driver");
                connection = DriverManager.getConnection(
                        "jdbc:mysql://localhost:3306/data", "root", "omfg123");
            }catch(ClassNotFoundException cnfe){
                cnfe.printStackTrace();
            }catch(SQLException sqle){
                sqle.printStackTrace();
        }Then, when you click the "Add" button, it executes this code:
                add.addActionListener(new ActionListener(){
                    @Override
                    public void actionPerformed(ActionEvent ae){
                        String employee = employeeName.getText();
                        String[] args = employee.split(" ");
                        firstName = args[0];
                        lastName = args[1];
                        execute();
                });And this is my "execute()" method:
         * Connects the servlet with the MySQL database.
         * - And executes the SQL queries.
        private void execute(){
            try{
                PreparedStatement statement = connection.prepareStatement("insert" +
                        " into employees values(" + firstName + ", " + lastName
                        + ")");
                ResultSet result = statement.executeQuery();
                String fullName = firstName + " " + lastName;
                printer.write("Employee " + fullName + " added.</br>");
            }catch(SQLException sqle){
                sqle.printStackTrace();
        }But when I click the "Add" button, nothing happens.

    This is what I use to insert into mysql. It works on windows.
    try {
                Class.forName("com.mysql.jdbc.Driver");
                String connectionUrl = "jdbc:mysql://" + loadip + "/custsig?" +
                        "user=root&password=";
                Connection con = DriverManager.getConnection(connectionUrl);
                newproc = jTextField1.getText();
                newsoft = jTextField2.getText();
                newdeb = jTextField3.getText();
                newcust = jTextField4.getText();
                if (newcust.equals("")) {
                    errorsig12 = 1;
                    jLabel1.setForeground(new java.awt.Color(255, 0, 0));
                } else if (newsoft.equals("")) {
                    errorsig12 = 1;
                    jLabel2.setForeground(new java.awt.Color(0, 0, 0));
                } else if (newproc.equals("")) {
                    errorsig12 = 1;
                    jLabel3.setForeground(new java.awt.Color(0, 0, 0));
                } else if (newdeb.equals("")) {
                    errorsig12 = 1;
                    jLabel4.setForeground(new java.awt.Color(0, 0, 0));
                if (errorsig12 == 0) {
                    PreparedStatement ps = con.prepareStatement("insert into customer set cust_name = ?,  software = ?, processor = ?, debit = ?");
                    ps.setString(4, newdeb);
                    ps.setString(3, newproc);
                    ps.setString(2, newsoft);
                    ps.setString(1, newcust);
                    int rs = ps.executeUpdate();
            } catch (SQLException eg) {
                System.out.println("SQL Exception: " + eg.toString());
            } catch (ClassNotFoundException cE) {
                System.out.println("Class Not Found Exception: " + cE.toString());
            }

  • How to create ShoppingCart By Using mysql+Servlet+Html

    Hi everyone:
    I am working on a project using Jbuilder, which is a shopping site.
    The functions are:
    1, Access database and display all kinds of products in a table
    2, Add the item you want into a Temporary Cart
    3, Remove unwanted items from cart
    4, Confirm the order
    I can only use mysql + Servlet + Html.
    I am at the step of display everything from the database, but i don't have any idea how to do the rest of the functions.
    i have read lots of information, it seems that i need to use session tracking, and connection pool stuff.
    Can any one give me some suggestions about how to design this project and how to implement it, and what kinds of thing i need to aware of.
    cheers
    Lin

    Hi,
    i have idea about ur app in different env i.e. in different servers but i don't know how it will impl in jbuilder.i will send u link of whole shop app and also u can refer the wrox books and site.

  • How to insert data into the mysql table by giving as a text file

    Hi,
    Any one know's how to insert data into the mysql table by giving as a text file as the input in JSP.Please respond ASAP.
    Thanks:)

    At least you can try StringTokenizer to parse your text files. Or download a text JDBC driver to parse your files, for instance, HXTT Text(www.hxtt.net) or StelsCSV(www.csv-jdbc.com).

  • How to enter a 24 digit number into a mysql db

    hi,
    i want enter a 24 digit number into a mysql db as a mathematically manipulatable value.
    when i configure the field as a bigint(24) it takes it as bigint(20)
    when i keep it as bigint and parsing a double value from my application
    it gives data truncation exception for the particular field.
    the whole process worked well when i change the field type to varchar(24),
    what i want is to enter 24 digit number into db as a mathematically manipulatable value.
    if anyone can assist me, pls reply,
    thanks,
    dushi

    you should ask in a mysql-forum. or at least in JDBC-forum here at sun-forums
    you could save it as varchar and parse it when selecting it into bigint in java and make your calculations...

  • Sending colour from a JSP page into a MySQL database field

    Dear All,
    I am working on trying to send different colours into a MySQL database field from a JSP page.
    This is so that I can represent different pieces of data on my webpage tables in different colours providing status depending on the user request.
    What is the best way to write JSP code for this?
    thanks,
    Alasdair

    Double-posted:
    http://forum.java.sun.com/thread.jspa?threadID=598637

  • I want to insert more than 4k data into the MySql

    hi there..
    i willing to support mysql.
    but there is one thing unsolved..
    i wanna insert more than 4k data into the mysql ..
    but i can't..
    does anyone know about this problem..
    i really appreciate for your advice in advance...
    thanz for reading...

    <PRE>
    hi there..
    first of all.. thanz 4 ur replies..
    i m using mysql 3.x
    and using mysql-connector-java-3.1.0-alpha
    source code is one of the sample apps..
    if u download jconnector3.1.0-alpha. u can see TestBlog.java file on 'testsuite/simple/'
    i changed db url, user, passwd atc..
    then, i execute TestBlob..
    can c following error message
    G:\MySql\mysql-connector-java-3.1.0-alpha\mysql-connector-java-3.1.0-alpha>java
    testsuite.simple.BlobTest
    Loading JDBC driver 'com.mysql.jdbc.Driver'
    Done.
    Establishing connection to database 'jdbc:mysql://xxx.xxx.xxx.xxx/devel'
    is else
    userid:'userid'
    passwd:'password'
    Done.
    error...
    java.sql.SQLException: Communication link failure: com.mysql.jdbc.PacketTooBigEx
    ception
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1079)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1142)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:1876)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.ja
    va:1590)
    at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1304)
    at testsuite.simple.BlobTest.testByteStreamInsert(BlobTest.java:114)
    at testsuite.simple.BlobTest.setUp(BlobTest.java:82)
    at junit.framework.TestCase.runBare(TestCase.java:125)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestCase.run(TestCase.java:111)
    at testsuite.simple.BlobTest.main(BlobTest.java:68)
    Loading JDBC driver 'com.mysql.jdbc.Driver'
    Done.
    Establishing connection to database 'jdbc:mysql://xxx.xxx.xxx.xxx/devel'
    is else
    userid:'userid'
    passwd:'password'
    Done.
    error...
    java.sql.SQLException: Communication link failure: com.mysql.jdbc.PacketTooBigEx
    ception
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1079)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1142)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:1876)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.ja
    va:1590)
    at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1304)
    at testsuite.simple.BlobTest.testByteStreamInsert(BlobTest.java:114)
    at testsuite.simple.BlobTest.setUp(BlobTest.java:82)
    at junit.framework.TestCase.runBare(TestCase.java:125)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestCase.run(TestCase.java:111)
    at testsuite.simple.BlobTest.main(BlobTest.java:69)
    at 68, 69 line of BlogTest.java
    public static void main(String[] args) {
    new BlobTest("testBytesInsert").run(); <--- 68 line
    new BlobTest("testByteStreamInsert").run(); <--- 69 line
    i need ur help..
    appreciate for your advices in advance..
    thanz
    </PRE>

  • Database query ResultSet from servlet to JSP page

              Hi there,
              I have an Access 2000 database. I am running Apache and Tomcat on Windows Me.
              I would like to know if it is possible for me to use a Servlet to search the
              database (I know this bit is possible!), but then I would like the servlet to
              forward to a jsp page which will then display the ResultSet that the servlet has
              retrieved, i.e. when forwarding from a servlet to a jsp, is it possible for the
              jsp page to have access to the servlet's data? I know that it gets access to
              the response and request objects, but what about a ResultSet?
              Sorry it this sounds a little silly - i am a bit of a newbie.
              Thanks in advance for your help,
              SJ
              

    HttpServletRequest.setAttribute let's you share data for a particular
              request. When you call forward you can store the resultset in the request.
              Make sure your JSP does close the result set though, because what you are
              trying to do doesn't sound good :)
              If you want to share data across the session, take a look at the HttpSession
              object.
              read through the servlet specification, it is fairly easy to read and will
              give you all the info you need
              Filip
              ~
              Namaste - I bow to the divine in you
              ~
              Filip Hanik
              Software Architect
              [email protected]
              www.filip.net
              "SJ" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Hi there,
              >
              > I have an Access 2000 database. I am running Apache and Tomcat on Windows
              Me.
              > I would like to know if it is possible for me to use a Servlet to search
              the
              > database (I know this bit is possible!), but then I would like the servlet
              to
              > forward to a jsp page which will then display the ResultSet that the
              servlet has
              > retrieved, i.e. when forwarding from a servlet to a jsp, is it possible
              for the
              > jsp page to have access to the servlet's data? I know that it gets access
              to
              > the response and request objects, but what about a ResultSet?
              >
              > Sorry it this sounds a little silly - i am a bit of a newbie.
              >
              > Thanks in advance for your help,
              >
              > SJ
              

  • Portable way to call Stored Procs. which return a ResultSet (MySQL/Oracle)?

    Hello!
    I have developed a Java application which calls stored procedures, some of which return a ResultSet (always one).
    I need to support more DBMS vendors, so I used the standard JDBC syntax to call the stored procedures ({call storedProcedure(?,?)}).
    I developed the code using MySQL, but succeded to call SQL Server 2000 stored procedures changing only the driver (that's the purpose of JDBC, right?).
    Now I need to support the Oracle DBMS, but I can't find a way to create a stored procedure which returns a result set and allows me not to change the already stable Java code.
    How could I achieve this result? Should I use some other Oracle object, say a function?
    By the way, I searched the Internet, but only found solutions which would've made me change code. This is definitely not portable
    Thank you very much for your help!
    PS: Some of the stored procedures return both a ResultSet AND OUT parameters.

    Hello and thanks for your reply, jwenting.
    However, keeping useless "philosophy" out of this thread, please just let me clarify that I obviously didn't want portability of stored procedures, I just wanted a standard JDBC to interface with them. I haven't had problems in the past with stored procedures and other DBMSs, I'm having them just now with the Oracle JDBC driver. Since JDBC is meant to be portable, I hoped there was a portable way of calling Oracle stored procedures (or whatever else in Oracle takes inputs and returns output and a ResultSet...). Unfortunately, there doesn't seem to be any, unless I use a commercial driver from DataDirect. I find this a heavy limitation of the Oracle JDBC driver, but, alas, here it is... I'll have to refactor my stable code...
    Thanks again...

  • Getting ResultSet from Servlet

    How can I send a ResultSet to a JSP page from a servlet? I tried to use the req.setAttribute("name", rs) and forward to JSP with RequestDispatcher, but I get this error in the JSP page when doing "ResultSet rs = request.getAttribute("nome")":
    incompatible types
    found : java.lang.Object
    required: java.sql.ResultSet
    As you can see, the resultset became a java.lang.Object. Is there a way to convert the object back to a ResultSet?

    [snip]
    As you can see, the resultset became a
    java.lang.Object. Is there a way to convert the object
    back to a ResultSet? not addressing whether it's a good idea to throw a ResultSet at a JSP or not...
    getAttribute returns an Object, you "convert" it back to what you stuffed in there by casting, as
    ResultSet rs = (ResultSet)request.getAttribute("nome");Good luck
    Lee

  • Returning ResultSet from servlet to jsp - java.lang.NullPointerException

    Hey all, i've been stuck on this for too long now...just trying to return a ResultSet from a servlet to jsp page.
    Had a bunch of problems earlier...which i think were fixed but...now i get a "java.lang.NullPointerException" in my jsp page when i try to get elements from the ResultSet object.
    Here is the latest version of my code:
    Servlet:
    String QueryStr="select ProdName from products";
    Statement stmt=conn.createStatement();
    rs=stmt.executeQuery(QueryStr); //get resultset
    sbean.setInventory(rs); //set ResultSet in bean
    req.getSession(true).setAttribute("s_resbean",sbean); //create session/request variable, set to bean
    Bean:
    package beans;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    import javax.sql.*;
    public class SearchBean extends HttpServlet{
         private int searchFlag=0;
         private ResultSet inventory;
         public SearchBean(){
         public int getSearchFlag(){
         return searchFlag;
         public ResultSet getInventory(){
              return inventory;
         public void setInventory(ResultSet rs){
              this.inventory=rs;
         public void setSearchFlag(){
              this.searchFlag=1;
    jsp:
    <%@ page language="java" import="java.lang.*,java.sql.*,javax.sql.*,PopLists.PopInvLists,beans.SearchBean"%>
    <jsp:useBean scope="session" id="s_resbean" class="beans.SearchBean" />
    <% ResultSet categories=PopInvLists.getCat();
    ResultSet manuf=PopInvLists.getManuf();
    ResultSet supplier=PopInvLists.getSupplier();
    ResultSet cars=PopInvLists.getCars();
    ResultSet search=(ResultSet)request.getAttribute("s_resbean");
    %>
    <%     while(search.next()){
         String pname=search.getString("ProdName");
    %>
    It craps out when i try to loop through the "search" ResultSet.
    I can loop through the rest of the ResultSets no problem....just this one doesn't work because it's set in a servlet, not a simple java class.
    Just to clarify, i am populating some dropdown lists on entry to the screen, which the user will use to perform a search. Once the search btn is clicked, the servlet is called, gets the request info for the search, performs search, and returns the resultset to the original screen. I want to eventually display the result under the search criteria.
    Someone....Please Please please tell me how to get this working...it should be very simple, but i just can't get it to work.
    Thanks in advance,
    Aditya

    req.getSession(true).setAttribute("s_resbean",sbean); //create session/request variable, set to beanHere you add an attribute to the session.
    ResultSet search=(ResultSet)request.getAttribute("s_resbean");Here you try to get the attribute from the request. Naturally it isn't there because you added it to the session, not the request. Despite your comment in the first line of code, a session is not a request. And vice versa.

  • Uploading pictures into database through servlet

    I'm having problems uploading pictures from servlet to a database:
    public Exception storePicture(byte[] bytes, String fileName){
              int fileNo;
              try{
                   if(!SELECT_FILENAME_NO.execute()){
                        return new Exception("number select");
                   ResultSet resultSet = SELECT_FILENAME_NO.getResultSet();
                   if( resultSet.next() ){
                        fileNo = resultSet.getInt( "nextval" );
                   }else{
                        return new Exception("resultset number");
                   INSERT_PICTURE_BYTES.setBytes(1, bytes);
                   INSERT_PICTURE_BYTES.setString( 2, fileName );
                   INSERT_PICTURE_BYTES.setInt(3, 0);
                   if(INSERT_PICTURE_BYTES.executeUpdate() > 0){
                        return new Exception("insert_bytes");
              } catch (SQLException e) {
                   e.printStackTrace();
                   return e;
              return new Exception("end");
         }with this code I get error message: Data size bigger than max size for this type: 142485.
    with a picture of only 150kB
    The exception is thrown on the setBytes line.
    I also tried to add
    ByteArrayInputStream input = new ByteArrayInputStream(bytes);
    INSERT_PICTURE_BYTES.setBinaryStream(1, input, bytes.length);and..
    InputStream in = input;
    INSERT_PICTURE_BYTES.setBinaryStream(1, in, bytes.length);...both giving error message: Io exception: Connection reset.
    The exception is thrown on the setBinaryStream line.
    I have never done this before and I can't figure out what to do. Anyone?
    thanks

    INSERT_PICTURE_BYTES = connection.prepareStatement("INSERT INTO pictures(picture, fileName, approved) values(?, ?, ?)");Io exception: Connection reset
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
    oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2061)
    oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
    oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
    oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
    rockIt.db.PictureDAO.storePicture(PictureDAO.java:113)
    rockIt.control.DbController.storePicture(DbController.java:201)
    servlets.main.Upload.doPost(Upload.java:69)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
    org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
    org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    java.lang.Thread.run(Thread.java:619)

  • New Bie help with MySQL & servlet

    Hi,
    I am trying to execute a small action... some how my code does not work. All it shows is a blank page with no error....
    Can any one help me to optimize this code so that it works?
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package oneword;
    import com.mysql.jdbc.Connection;
    import com.mysql.jdbc.Statement;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.util.Random;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class Register extends HttpServlet {
        private String name = null;
        private String emailID = null;
        private String nameDB = "jdbc:mysql://localhost:3306/register";
        private String mysqlUser = "root";
        private String mysqlPassword = "abc";
        private String mySqlJdbcDriver = "com.mysql.jdbc.Driver";
        private Connection conn = null;
         * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, ClassNotFoundException, SQLException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            name = request.getParameter("_name");
            emailID = request.getParameter("_email");
            try {
                Random generator = new Random();
                int activationPassword = generator.nextInt(100000);
                Class.forName(mySqlJdbcDriver);
                conn = (Connection) DriverManager.getConnection(nameDB,mysqlUser,mysqlPassword);
                Statement statement = (Statement) conn.createStatement();
                String sqlCommand = "INSERT INTO userdata(name, email, validation, " +
                        "banned, activatepassword, password)values("+name+", "+emailID+", 0, 0,"+activationPassword+", 'ddd')";
                statement.executeQuery(sqlCommand);
                out.println(name);
                out.println("<br>"+emailID);
                out.println("rows affected:");
                conn.close();
            } catch (SQLException ex) {
            // handle any errors
            System.out.println("SQLException: " + ex.getMessage());
            System.out.println("SQLState: " + ex.getSQLState());
            System.out.println("VendorError: " + ex.getErrorCode());
            } finally {
                out.close();
        // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
         * Handles the HTTP <code>GET</code> method.
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            try {
                processRequest(request, response);
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(Register.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(Register.class.getName()).log(Level.SEVERE, null, ex);
         * Handles the HTTP <code>POST</code> method.
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            try {
                processRequest(request, response);
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(Register.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(Register.class.getName()).log(Level.SEVERE, null, ex);
    }Thank you

    A blank page usually indicate that an exception is been thrown but cannot be displayed because the response is already started/committed/processed. Just read the appserver's logs as usual for the details.
    Your servlet class does way too much. You're mingling all the processing steps together in one class. This is simply asking for trouble. Use a DAO class for accessing the DB. Use a JSP file for presentation. Use a business object to process the input/output data. Use a servlet for controlling the request. To start off, you may get some ideas out of this article and the JSP/Servlet follow-up: [http://balusc.blogspot.com/2008/07/dao-tutorial-data-layer.html].
    Oh, your JDBC code is not safe against SQL injection attacks either.

  • How to get data into the mySQL database?

    First some background.
    I have a website that has outgrown its designed dimensions and is a huge burden to maintain. See PPBM5 Benchmark
    There is a lot of maintenance work involved, so I'm investigating a PHP/MySQL approach to easen the burden and to add functionality to the site. With the current Excel based structure and over 420 entries, it is cumbersome for me to maintain, but also for users to find what they need.
    A MySQL based dynamic structure is a lot easier and offers vastly more selection capabilities, like selecting only records that meet specific criteria.
    Data submission is done with a form, that contains most of the relevant data, but the drawack is that people submitting their data are often not technically inclined, give wrong answers due to a lack of understanding or making typo's. The test results are attached in one or two separate .txt files, but often they have not read the instructions correctly or did something wrong, so these attached .txt files can not be trusted automatically, they have to be checked before inclusion.
    These were my initial thoughts:
    1. Data collection:
    To avoid spending all our energy and time  on correcting typo's, getting missing data, correcting errors, I am  investigating the use of CPU-Z in Ghost mode to create a .txt or .html  file that contains all relevant hardware info we need and even more. It gives all the info we currently have, but adds  data like number of memory sticks, DDR timings, stock clock speed and  BCLK setting, video card info and VRAM size, etc.
    To see what I mean, run CPU-Z, go to the About tab and press the Save Report button and look at the results.
    This can all be done without user intervention in an automatic way, but  maybe I need to add an Auto-It file to the test to make it all run as  desired.
    If this works and I'm able to extract the relevant data from the created  file and can insert it into the database, we may be in business for the  next version of PPBM5.5 or PPBM6. It does require a modification to the instructions, making them a lot  easier, because there is less data to fill out.
    2. Data submission:
    The submission form can be simplified if  the CPU-Z data can be used. We have to create an automatic way to attach  the created .html file from CPU-Z to the submission form and we have to  streamline the Output.txt and Output-MPE.txt files to be more easily included in the 'form.lib.php' file. It  currently is manual labor and very time consuming.
    3. Adding to Database:
    I have to find a way to create database  records from the Gmail forms I receive. All incoming mail messages need  to be checked on relevancy and if relevant, need to be added  automatically to the database and then offered for approval before final inclusion in the database. Data included in the database  will then include submission date and time, Email address,  IP address  used, plus links to the files submitted and available on the website.
    4. Publication of the database:
    After approval of new records from step  3, all updates will be automatically applied to the database and  accessible for users. I do not yet intend to introduce a user account ,  requesting login before all functionality is accessible. Too much trouble and administration.
    Queries should be possible on things like CPU (check box), so include  17-920, i7-930, i7-950 but exclude i7-980X and i7-990X, Size of memory  (check box), Overclocked (boolean, yes, no), SSD as OS disk, and similar  options.
    The biggest problem is to keep the color grading and statistical  indicators (Top, D9, Q3, Med, Q1 and D1) intact on dynamically generated  queries. Say you make a query which results in 20 observations, this  should show the related colors and legends. Next query results in 48 observations and of course the color grading and legends  do need to reflect that. Question in my mind, does the RPI remain  constant, independent of the query or does that need to be recalculated  on the basis of the query?
    Next thing is to allow a user to select a specific observation and by  simply clicking on it be shown, in a separate window (detail page) or  accordion, all the CPU-Z related information about the hardware.
    The graphs, Top-20 and MPE Gains, need to be dynamically adjusted, based on the query used.
    5. Ideally, external links:
    In an ideal situation, one could link the  CPU-Z data to external price databases, looking up current prices for  CPU, memory, video card, disks, raid controller, etc. to get instant  BFTB charts, based on the query made. But that is the next step.
    Situation now:
    I have a MySQL database that is easily updated with the new submissions. Simply create a .CSV flie from the submitted forms and import that into the database. The bulk of the initial work is done.Lots remain to be done as you can see above, but that is for a later time.
    Question:
    I have this table, that needs to be filled with data in the submitted and attached files. Mr. X submitted his data and can be uniquely identified by his "Ref_ID". He attached one or two files in .TXT format with the relevant test data. These files are stored on the server with a concatenated name:
    "Ref_ID","-","filename"
    Say his Ref-ID is: 20110204-6cf5 and his submitted file is called: Output(99).txt then the file can be found on the server as
    20110204-6cf5-Output(99).txt
    I need to be able to open that comma delimited file, the contents may look like this: "439","1036","819","531" and insert these contents into the relevant record and fields.
    Graphically,
    is what I want to achieve.
    This being my first exposure to PHP/MySQL, you can imagine I'm not clear on how to go from here.
    Added complication is that I actually have 5 numbers to insert per record and two calculated fields, Total Score and RPI should be calculated fields. Haven't yet figured out how to handle calculated fields, maybe only in the PHP/HTML code and not in the database.
    I hope someone can help me.

    You do have a very complex looking site and may need several tables in mysql to handle all that data. If you knew to phpmysql I would suggest taking a look at this tutorial it will help get you started in understanding how to $_GET info from a database and also how to $_POST data to a database. I am no expert just learning myself and I found this very helpful. This is the link http://www.adobe.com/devnet/dreamweaver/articles/first_dynamic_site_pt1.html
    There are also many tutorials on Youtube to help build a CMS Content Management Site I would suggest the following: -
    http://www.youtube.com/user/phpacademy
    http://www.youtube.com/user/betterphp
    http://www.youtube.com/user/flashbuilding
    And many more on my channel here
    http://www.youtube.com/user/Whisperingonthewind
    CMS's are easier to maintain, add edit and delete content.
    I have also recently bought a Book by David Powers Training from the Source very helpful.
    Anyway hope you get it sorted.

  • How to Insert a record into a MySql database.

    Hi,
    In an earlier question I was advised to use the Adobe extension to get access to database connectivity and server behaviours.
    That extension is now installed. Whether it is functional is another question.
    To chewck it out I follwed exactly the steps set out in Lessons 5 and 6 of Dreamweaver CS5 with PHP
    When trying to make a database connection I am still getting the 404 error I mentioned in an earlier email. However if I type the database name (phpcs5) into the “select database” box and test it says I connected successfully and I can see the user’s table in the database panel.
    So far apparently so good.
    I have created the cs5wtite and cs5read connections to the phpcs5 database
    I set up the insert record behaviour using “Form1!, “cs5write”, “users”,
    Everything went as per the manual, the file turned aqua in Live view.
    I entered data and ctrl/clicked “Sign me up” button and nothing happened.
    No data was entered into the database and I was not passed to login.php.
    I deleted everything from the computer, restarted the pc and started again from scratch.
    The result was the same. Nothing
    My one concern was line 49  $insertGoTo = " login.php";
    The file is in registration so I changed to $insertGoTo = "registration/login.php";
    but that made no difference.
    Is there any logging or error reporting I can use to see where it is going wrong?
    This is the add user page generated
    <?php require_once('../Connections/cs5write.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO users (first_name, family_name, username, password) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['first_name'], "text"),
                           GetSQLValueString($_POST['surname'], "text"),
                           GetSQLValueString($_POST['username'], "text"),
                           GetSQLValueString($_POST['password'], "text"));
      mysql_select_db($database_cs5write, $cs5write);
      $Result1 = mysql_query($insertSQL, $cs5write) or die(mysql_error());
      $insertGoTo = "login.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Add new user</title>
    <link href="../../styles/users.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <h1>Sign Up Now</h1>
    <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
      <fieldset>
        <legend>Just a few details and you&rsquo;re in</legend>
        <p>
          <label for="first_name">First name:</label>
          <input type="text" name="first_name" id="first_name" />
        </p>
        <p>
          <label for="surname">Family name:</label>
          <input type="text" name="surname" id="surname" />
        </p>
        <p>
          <label for="username">Username:</label>
          <input type="text" name="username" id="username" />
        </p>
        <p>
          <label for="password">Password:</label>
          <input type="password" name="password" id="password" />
        </p>
        <p>
          <label for="conf_password">Confirm password:</label>
          <input type="password" name="conf_password" id="conf_password" />
        </p>
        <p>
          <input type="submit" name="add_user" id="add_user" value="Sign me up!" />
        </p>
      </fieldset>
      <input type="hidden" name="MM_insert" value="form1" />
    </form>
    </body>
    </html>
    This is the connection page
    <?php
    # FileName="Connection_php_mysql.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_cs5write = "localhost";
    $database_cs5write = "phpcs5";
    $username_cs5write = "cs5write";
    $password_cs5write = "Smp??2014";
    $cs5write = mysql_pconnect($hostname_cs5write, $username_cs5write, $password_cs5write) or trigger_error(mysql_error(),E_USER_ERROR);
    ?>
    I understand this solution is a wokraround Adobe privided whist deprecating its use.
    In the earlier question I asked if there was another way to work with a database. Someone posted a link to an Object orientated solution but It was way beyond my coding abilities. I wonder are there any other solutions out there?
    Thanks for any input

    Hi,
    Thanks for the test.
    I used your amendment but still got nothing, no record in database and not sent to login page..
    I also tried this code below. It returns "Record added to database" but it was not.
    Something strange going on.
    <?PHP
    $user_name = "cs5write";
    $password = "Smp??2014";
    $database = "phpcs5";
    $server = "127.0.0.1";
    $db_handle = mysql_connect($server, $user_name, $password);
    $db_found = mysql_select_db($database, $db_handle);
    if ($db_found) {
    $SQL = "INSERT INTO users (first_name, surame, username, password) VALUES) VALUES ('Albert', 'Dent', 'hitchiker', 'space')";
    $result = mysql_query($SQL);
    mysql_close($db_handle);
    print "Records added to the database";
    else {
    print "Database NOT Found ";
    mysql_close($db_handle);
    ?>

Maybe you are looking for

  • Issue in IDOC-XI-IDOC scenario

    Hi, We are facing a strange issue in an IDOC-XI-IDOC scenario. We are using a SAX parser to parse the code here. The error we are getting in 'sxmb_moni' is <SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>   <SAP:P1>com/abc/def/dev/sapxi/c

  • Microsoft Word 2008 Spacing

    I know this probably isnt the "right" place for this question but Microsoft support forums are terrible so maybe someone here can help me. I have Microsoft Office 2008 and I the spacing between lines is too large, so I go to paragraph formatting and

  • Sort_area_size & hash_area_size on 10g

    I am confused as to whether I need to have sort_area_size and hash_area size set in my 10.2.0.3 database. I know the Oracle documentation states the following: "Oracle does not recommend using the SORT_AREA_SIZE parameter unless the instance is confi

  • Music Store purchases in my Shopping Cart

    I am receiving error today when trying to purchase songs listed in my shopping cart. Error states that credit card processing is temp unavailable and to try again soon. Is anyone else having this problem today...Saturday, Dec 03? Thx... Carlton

  • Looking for HP8720C Network Analyzer Drivers

    Also I am new to Labview, what would be a better option, to write in Labview or Visual Basic