Writing to a MySQL

Currently I am working on a project where I need a way for the java applet to write to a remote location such as MySQL or some other way. Any Ideas?

By default, an applet can only open a connection back to the host that served it. If the MySQL server is located on the same host that served up the applet, OR if the applet is signed and the user has given it the proper permissions to access another host, then you can do it.

Similar Messages

  • Reading and writing to a MySQL database with Java

    Anyone knows what's the best way to read and write from a MySQL database?

    > Anyone knows what's the best way to read and write
    from a MySQL database?
    Yep!
    The Java� Tutorial - Trail: JDBC� Database Access
    MySQL Reference Manual
    MySQL Connector/J Documentation
    Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J
    Best of luck!
    ~

  • Time-out on MySQL

    hi all,
    I am facing a crisis here. The situation is such:
    Operating System : Solaris
    Java Server : Apache Tomcat
    Database : MySQL
    Technology : JSP, INet Crystal
    I am running a JSP page that pushes a lot of data (and I mean a lot) into MySQL. Afterwhich, I will call the Inet crystal report to generate a report based on those data. But the problem is the Inet Crystal doesn't fire.
    I checked the database and all the records are inserted correctly.
    However, on my webpage, it shows page loading and just kept on loading without any further progress.
    What is wrong here?
    Time-out on Tomcat? MySQL didn't pass the handler back to Tomcat/JSP?
    Help, please.
    Nicholas

    If this is still an issue can you post the snippet of code that deals with writing to the mySQL db so I can have a look at it... on first glance it sounds like there's an infinite loop in there somewhere so I'd check for that.
    Cheers.

  • Unable to write to MySQL database

    hi all,
    I'm currently having a problem writing to my MySQL database. Everything is setup correctly and I'm able to read from it. I'm writing a simple enough java application and have no idea why it wont write to it. All insert statements etc are correct aswell. Anybody have any ideas why?

    Best guess: you are doing something wrong.
    Perhaps you should repost the question (although with more details, we have nothing to go on exception your assertions that you are correct) in the JDBC forum. The problem is unlikely to have anything to do with servlets.

  • Update/Insert records from Oracle to MySQL

    Hi team, 
    My application will insert/update records into Oracle database, I need to sync all of records into MySQL database.  I designed a package to load data from Oracle to MySQL, the Oracle database use OLE DB component and MySQL database use ADO.NET.
    How to insert new records into MySQL? If the old record exists, we also need to replace with new record. I did some research, someone suggest to create a stage table to handle this scenario, but I have 14 tables in this case. How to handle this scenario
    with high performance? 
    If there is anything unclear, please let me know. 
    Thank you in advance. 

    Finally, I created 14 tables as same as in our MySQL database system with prefix "updated" , they are use to store the updated records from Oracle system. All of new records we add a flag, the "1" means insert a new record into the system,
    and the "0" means we should updated. So, I can use the conditional split component to split all of new records. The new records insert into the target table and the updated records insert into the "updated_table". Finally, we can add a
    SQL Script task to run a update script to sync all of records. 
    I don't use Lookup Transformation because we must use Cache
    Transform transformation in this case, the Cache connection manager to save the data to a cache file (.caw), it will hard to
    trace the history data in the future.  
    In addition, I recommend to use ODBC connection if somebody face the similar scenario with me, there is a bug  if we use ADO.NET to
    load data from Oracle to MySQL by using SSIS. For more information, please refer the MSDN document: http://blogs.msdn.com/b/mattm/archive/2009/01/07/writing-to-a-mysql-database-from-ssis.aspx
    @Arthur, thanks again for your input.  Have a nice day! :)

  • Mini-Calendar Navigation

    Is there an easy way to have a Outlook/Blog style
    Mini-Calendar Navigator as part a web page? I would prefer
    something in PHP that I could connect to my own MySQL db if
    possible.
    What I would like to have is a 3 month view calendar on the
    left hand side the would have highlighted dates (from a date field
    in the MySQL db). If the user clicks on the highlighted date then
    the right side would load the record from the db into the fields on
    the right side. If the user taps an unhighlighted date then a new
    record form would pop-up.
    I don't mind writing PHP or MySQL stuff but I was hoping
    there might be something close that I could modify or even better a
    reasonably priced component for Dreamweaver.
    Hope someone can help with this.
    Thanks
    Jayne

    I am experiencing this same issue. Specifically, the month label at the top of the mini-calendar always seems to be one month behind the days that are being displayed below it.

  • Time out on bank website

    Been using online banking for months. Yesterday when I clicked on Pay Bills I got an error message that says Billpay.suntrust.com
    Timed out.
    I can access all other items on checking acct, just not bill pay.

    If this is still an issue can you post the snippet of code that deals with writing to the mySQL db so I can have a look at it... on first glance it sounds like there's an infinite loop in there somewhere so I'd check for that.
    Cheers.

  • HT4972 time out on updates

    cant update iphone ipod or ipad. update times out. have cleared dns file, turned sucurity off. my connection is fine as updated my blackberry playbook which was 729mb with no problems. have tried 2 different internet connections and 3 different computers.

    If this is still an issue can you post the snippet of code that deals with writing to the mySQL db so I can have a look at it... on first glance it sounds like there's an infinite loop in there somewhere so I'd check for that.
    Cheers.

  • Tasks / time out on machines?

    10.4.8 /ard3/macbookpro
    if i have a task that involves a large number of macs, how do i make sure a client is time out / given up after a certain time if doesnt answer / isnt succesfull?
    any best practice, tip I am missing?
    victoria

    If this is still an issue can you post the snippet of code that deals with writing to the mySQL db so I can have a look at it... on first glance it sounds like there's an infinite loop in there somewhere so I'd check for that.
    Cheers.

  • Writing Login.jsp and authenticating a user who have stored in MySql DB

    Hi Friends,
    My project requirement is: Need to write a login page must send the request to servlet is the user and password avail in mysql db, if yes servlet should forward the home page else error message. Tools i need to use is IDE=eclipse, Server = tomcat, database = MySql
    Here is source:
    pls tell me where i m wrong.
    Login.jsp
    <%@ page language="java" %>
    <html>
    <head>
    <title>Login Page</title>
    <script language = "Javascript">
    function Validate(){
    var user=document.frm.user
    var pass=document.frm.pass
    if ((user.value==null)||(user.value=="")){
    alert("Please Enter user name")
    user.focus()
    return false
    if ((pass.value==null)||(pass.value=="")){
    alert("Please Enter password")
    pass.focus()
    return false
    return true
    </script>
    </head>
    <body>
    <h1>Login
    <br>
    </h1>
    <form name="frm" action="/LoginAuthentication" method="Post" onSubmit="return Validate()" >
    Name:
    <input type="text" name="user" value=""/><br>
    Password:<input type="password" name="pass" value=""/><br>
    <br>
    <input type="submit" value="Login" />
    <input type="reset" value="forgot Password" />
    </form>
    </body>
    </html>
    Servlet Code:
    LoginAuthentication.java
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.ServletContext;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.http.HttpSession;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.util.List;
    import java.util.ArrayList;
    public class LoginAuthentication extends HttpServlet{
    private ServletConfig config;
    public void init(ServletConfig config)
    throws ServletException{
    this.config=config;
    //public void init() {
    // Normally you would load the prices from a database.
    //ServletContext ctx = getServletContext();
    // RequestDispatcher dispatcher = ctx.getRequestDispatcher("/HomePage.jsp");
    //dispatcher.forward(req, res);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException,IOException{
    PrintWriter out = response.getWriter();
    String connectionURL = "jdbc:mysql://127.0.0.1/SRAT";
    //String connectionURL = "jdbc:mysql://192.168.10.59/SRAT";
    //127.0.0.1
    //http://localhost:3306/mysql
    Connection connection=null;
    ResultSet rs;
    String userName=new String("");
    String passwrd=new String("");
    response.setContentType("text/html");
    try {
    // Load the database driver
    Class.forName("com.mysql.jdbc.Driver");
    // Get a Connection to the database
    connection = DriverManager.getConnection(connectionURL, "admin", "admin");
    //Add the data into the database
    String sql = "select user,password from login";
    Statement s = connection.createStatement();
    s.executeQuery (sql);
    rs = s.getResultSet();
    while (rs.next ()){
    userName=rs.getString("user");
    passwrd=rs.getString("password");
    rs.close ();
    s.close ();
    }catch(Exception e){
    System.out.println("Exception is ;"+e);
    if(userName.equals(request.getParameter("user"))
    && passwrd.equals(request.getParameter("pass"))){
    out.println("WELCOME "+userName);
    else{
    out.println("Please enter correct username and password");
    out.println("<a href='Login.jsp'><br>Login again</a>");
    Deployment Descriptor for TOMCAT
    web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>
    SRAT</display-name>
    <welcome-file-list>
    <welcome-file>login.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
    <servlet-name>LoginAuthentication</servlet-name>
    <servlet-class>LoginAuthentication</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>LoginAuthentication</servlet-name>
    <url-pattern>/LoginAuthentication</url-pattern>
    </servlet-mapping>
    </web-app>
    PLS HELP ME.
    S. Udaya Chandrika

    I too have used the same code but its giving the following error:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Wrapper cannot find servlet class Validation or a class it depends on
         org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
         org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
         org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
         org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
         org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         java.lang.Thread.run(Unknown Source)
    root cause
    java.lang.ClassNotFoundException: Validation
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
         org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
         org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
         org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
         org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
         org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         java.lang.Thread.run(Unknown Source)
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
    Apache Tomcat/6.0.18
    Please some one help??

  • Spry validation stops me writing a MySQL record

    Good morning,
    This is very strange and has been driving me nuts for a couple of days now. Using DW CS6/ Win 7/ IE 11/ FF/ Chrome.
    I had an application form that worked correctly, validated input and wrote a new record to a MySQL db. I had to develop a very similar web page so I took the existing page and updated it.
    I have found, after a lot of trial and error, that I can write a new record containing valid data but spry doesn't work - no validation and no hints appear in the text boxes. Or, I can get spry validation to work but the web page hangs when I try and write a new record.
    Amongst other changes, the old page had a checkbox which I deleted from the new page and there are no other checkboxes on the page. When i remove the js  "var sprycheckbox2 = new Spry.Widget.ValidationCheckbox("sprycheckbox2");" Spry validation works, hints appear etc but the page hangs when I click the "Next Step" button which should write to the db. if I leave the js for the widget in the page I don't get any spry validation or hints but the record is written to the db. In both cases I had commented out the link to "SpryValidationCheckbox.js".
    Here's a link to the version which has the widget http://www.hollisterairshow.com/rally/vendorApp2.php?blapp=inline&tspapp=inline&tfpapp=inl ine , this has no hints in the text boxes and spry validation doesn't happen at all, but it does write a record to the db. here's a link to the version where I commented out the js for the checkbox widget - it's the second one in the list of widgets at the end of the page. I made no other changes http://www.hollisterairshow.com/rally/vendorApp3.php?blapp=inline&tspapp=inline&tfpapp=inl ine
    It looks like the widgets were added at the end of the google analytics code but I don't know if this is relevant.
    I'm also getting widgets listed as missing when I open the page in DW, the checkbox I referred to is the first one listed below, could this be relevant? Do I just delete the js for each of the widgets listed?  Sorry if this is a basic question, I'm getting very confused at this point.
    i'd really appreciate some direction in trying to fix this.
    Thanks,
    Tony

    I took a look at jqueryvalidate and it looks straightforward, my only reservation is that it doesn't appear to support hints in the form fields e.g. in a zip code field "5 digit Zip" etc. I googled around and found yet another library that claims to do this. So now I'm looking at adding two libraries I'm not familiar with and rewriting my form.
    I was really hoping a fresh pair of eyes could spot something I'm missing - the old version of this form worked, and still works. When I added/ deleted a few fields to the new version my problems started.
    Thanks again..

  • Writing multiple rows in one line, mysql statement. No strings are saved

    Hi, I dont know how to make multiple rows inputs into the table in one sentence. Ive got an error: "java.sql.SQLException: Statement parameter 2 not set" provided by code below. It works fine for one Date row (saves in the db corectly) however when I use for two different date types two single statements it will write databes two times putting 2x Null in the every other row. I dont want that, I need it to be written in one connection and statement.
    try{
         String userName = "user";
              String password = "pass";
              String url = "jdbc:mysql://dbadress/dbname";
              Class.forName ("com.mysql.jdbc.Driver").newInstance();
              Connection con = DriverManager.getConnection (url, userName, password);
              Statement  st1=con.createStatement();
           Date BirthDate = wdContext.currentPeopleElement().getBirthDate();  //People - context node, BirthDate - context attribute
           Date FillDate = wdContext.currentContextElement().getFillDate();
           String sql1 = "INSERT INTO table1 (BirthDate1,FillDate1) VALUES (?,?)"; //BirthDate1,FillDate1 - rows in the "table1" table
           PreparedStatement stmt1 = con.prepareStatement(sql1);
           stmt1.setDate(1, BirthDate);
           stmt1.setDate(1, FillDate);
           stmt1.executeUpdate();
           stmt1.close();
         catch(Exception e) {
         wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
    I would like to know how to fix it.
    Other issue is that code below:
    try{
         String userName = "user";
              String password = "pass";
              String url = "jdbc:mysql://dbadress/dbname";
              Class.forName ("com.mysql.jdbc.Driver").newInstance();
              Connection con = DriverManager.getConnection (url, userName, password);
              Statement  st1=con.createStatement();
           Date BirthDate = wdContext.currentPeopleElement().getBirthDate();  //People - context node, BirthDate - context attribute
           String sql1 = "INSERT INTO table1 (BirthDate1) VALUES (?)"; //BirthDate1 row in the "table1" table
           PreparedStatement stmt1 = con.prepareStatement(sql1);
           stmt1.setDate(1, BirthDate);
              stmt1.executeUpdate();
           stmt1.close();
         catch(Exception e) {
         wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
    works perfectly fine. It does write date in the database as shown on the monitor hoever it doesnt work if we change Date type with String. Of course context nodes are String type as well. Code below will write "Null" value in the db. Dont know why. Of course I write some string down in the input field and save after, just like do it with Date type which works fine. Please advice.
    try{
         String userName = "user";
              String password = "pass";
              String url = "jdbc:mysql://dbadress/dbname";
              Class.forName ("com.mysql.jdbc.Driver").newInstance();
              Connection con = DriverManager.getConnection (url, userName, password);
            Statement  st2=con.createStatement();
         String signature = wdContext.currentContextElement().getsignature(); //signature - context
         String sql2 = "INSERT INTO table1 (signature1) VALUES (?)"; //signature1 - name of row in the table1
         PreparedStatement stmt2 = con.prepareStatement(sql2);
         stmt2.setString(1, signature);
         stmt2.executeUpdate();
         stmt2.close();
         catch(Exception e) {
         wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
    Regards, Blamer.

    Hi,
    Fix for your first issue
    I dont know how to make multiple rows inputs into the table in one sentence. Ive got an error: "java.sql.SQLException: Statement parameter 2 not set" provided by code below. It works fine for one Date row (saves in the db corectly) however when I use for two different date types two single statements it will write databes two times putting 2x Null in the every other row. I dont want that, I need it to be written in one connection and statement.
    try{
         String userName = "user";
              String password = "pass";
              String url = "jdbc:mysql://dbadress/dbname";
              Class.forName ("com.mysql.jdbc.Driver").newInstance();
              Connection con = DriverManager.getConnection (url, userName, password);
              Statement  st1=con.createStatement();
           Date BirthDate = wdContext.currentPeopleElement().getBirthDate();  //People - context node, BirthDate - context attribute
           Date FillDate = wdContext.currentContextElement().getFillDate();
           String sql1 = "INSERT INTO table1 (BirthDate1,FillDate1) VALUES (?,?)"; //BirthDate1,FillDate1 - rows in the "table1" table
           PreparedStatement stmt1 = con.prepareStatement(sql1);
           stmt1.setDate(1, BirthDate);
           stmt1.setDate(1, FillDate);
           stmt1.executeUpdate();
           stmt1.close();
         catch(Exception e) {
         wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
    I would like to know how to fix it.
    Change the line  stmt1.setDate(1, FillDate); to stmt1.setDate(2, FillDate);
    As a workarond for your following issue
    works perfectly fine. It does write date in the database as shown on the monitor hoever it doesnt work if we change Date type with String. Of course context nodes are String type as well. Code below will write "Null" value in the db. Dont know why. Of course I write some string down in the input field and save after, just like do it with Date type which works fine. Please advice.
    try{
         String userName = "user";
              String password = "pass";
              String url = "jdbc:mysql://dbadress/dbname";
              Class.forName ("com.mysql.jdbc.Driver").newInstance();
              Connection con = DriverManager.getConnection (url, userName, password);
            Statement  st2=con.createStatement();
         String signature = wdContext.currentContextElement().getsignature(); //signature - context
         String sql2 = "INSERT INTO table1 (signature1) VALUES (?)"; //signature1 - name of row in the table1
         PreparedStatement stmt2 = con.prepareStatement(sql2);
         stmt2.setString(1, signature);
         stmt2.executeUpdate();
         stmt2.close();
         catch(Exception e) {
         wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
    Try as follows
    PreparedStatement stmt2 = con.prepareStatement(sql2);
         stmt2.setString(1, (signature == null ? "Value missing" : signature));
         stmt2.executeUpdate();
         stmt2.close();
    If the context attribute is null it will enter the text "Value Missing",
    Regards
    Ayyapparaj

  • Awt.image writing to mysql

    I am trying to write an Image datatype to a mysql database. The problem is that all the tutorials and books tell you how to do this directly from a file then get a filestream etc etc.
    I am working on the server side of a system so the image wont have come from that system. Therefore i can not give a filename or a path. HOW to i get the image to write to the database in its current state?
    thanks

    Is there anyway to get the ImageIcon or Image
    datatypes into a form where they could be written to
    the database? Is there a way even to convert back
    from
    Image image; to File file?Assuming that you are using javax.swing.ImageIcon:
    This class is serializable:
    http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/ImageIcon.html
    http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html
    http://java.sun.com/docs/books/tutorial/essential/io/serialization.html
    Therefore, you could serilize the object which turns it into a stream of bytes and save it to the database using what I mentioned in my previous post and unserialize it to get it back to its original state. There are some possible issues because serializing objects in not really intended for long term storage (versions change, etc.).
    There is also XML object storage - you should find an article about it if you search this site.

  • Servlet with Issues writing to MySQL Database using JNDI

    I'm hung on one servlet for my site. It compiles fine, and is accessed fine by the JSP, but doesn't do as I intended: write my blog entries to the MySQL database!
    As mentioned in the title, I'm using JNDI for connection pooling, via META-INF/context.xml.
    I'm also using JDBC Realm with a form, and that's working just fine, so I'm sure my issue isn't context.xml, as it seems to be overriding Tomcat's context file just fine, at least for authentication.
    Below is the code from the servlet, to include the annotations:
    package projectEgress.web.blog;
    import java.io.*;
    import java.text.*;
    import java.sql.*;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.*;
    public final class blogInput {
         /* bean properties */
        private String blogHeader;
        private String blogSubheader;
        private String blogBody;
        private String externalLinks;
        Connection conn;
        Statement stmt;
            /* getters & setters */
            public String getBlogHeader() {
                return blogHeader;
            public void setBlogHeader(String blogHeader) {
                this.blogHeader = blogHeader;
            public String getBlogSubheader() {
                return blogSubheader;
            public void setBlogSubheader(String blogSubheader) {
                this.blogSubheader = blogSubheader;
            public String getBlogBody() {
                return blogBody;
            public void setBlogBody(String blogBody) {
                this.blogBody = blogBody;
            public String getExternalLinks() {
                return externalLinks;
            public void setExternalLinks(String externalLinks) {
                this.externalLinks = externalLinks;
            /* like it says, a void which writes to the database */
            public void writeToDatabase() {
                /* create the query string to fill the table */
                String query = "insert into blogEntry (blogHeader, blogSubheader, blogBody, externalLinks) values (\"" + this.blogHeader + "\", \"" + this.blogSubheader + "\", \"" + this.blogBody + "\", \""  + this.externalLinks + "\")";
                try {
                    /*establish the datasource and make the connection */
                    Context ctxt =  new InitialContext();
                    DataSource dsrc = (DataSource)ctxt.lookup("java:comp/env/jdbc/projectEgress");
                    conn = dsrc.getConnection();
                    stmt = conn.createStatement();
                    /* Add data to table 'blogEntry' in our database */
                    int input = stmt.executeUpdate(query);
                    /* close the connections */
                    stmt.close();
                    conn.close();
                    /* check for exceptions, ensure connections are closed */
                    } catch (SQLException sqlx) {
                        sqlx.printStackTrace();
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    } finally {
                        if (stmt != null) {
                            try {
                                stmt.close();
                        } catch (SQLException sqlx) {}
                        if (conn != null) {
                            try {
                                conn.close();
                        } catch (SQLException sqlx) {}
            Here are the settings I have in META-INF/context.xml (sans Realm stuff, which works):
    <Context debug="1" reloadable="true">
        <Resource name="jdbc/projectEgress"
            auth="Container"
            type="javax.sql.DataSource"
            username="********"
            password="********"
            driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost:3306/projectEgress?autoReconnect=true"
            validationQuery="select 1"
            maxActive="15"
            maxIdle="8"
            removeAbandoned="true"
            removeAbandonedTimeout="120" />
        <WatchedResource>WEB-INF/web.xml</WatchedResource>
        <WatchedResource>META-INF/context.xml</WatchedResource>
    </Context>And, finally, the code I'm using in the JSP which calls the method (the form action is directed to this file's URL):
        <jsp:useBean id="blogInput" class="projectEgress.web.blog.blogInput">
        <jsp:setProperty name="blogInput" property="*" />
            <jsp:scriptlet>blogInput.writeToDatabase();</jsp:scriptlet>
        </jsp:useBean>
        -YES, I know I'm using a scriptlet in a JSP... I really don't want to create a custom tag to call the method, at least not until I'm far along enough in the project to justify creating a library... let's make it all work, first! :o)
    FINALLY, the form:
    <form action="/projectEgress/area51/blogInput" method="post" id="adminForm" enctype="application/x-www-form-urlencoded">
         <div>
            <span class="inputheader">Blog Header</span><br />
          <input type="text" name="blogHeader" size="35" class="form" /><br />
            <span class="inputheader">Blog SubHeader</span><br />
          <input type="text" name="blogSubheader" size="45" class="form" /><br />
            <span class="inputheader">Blog Body</span><br />
          <textarea class="content" name="blogBody" rows="9" cols="60"></textarea><br />
            <span class="inputheader">External Links</span><br />
          <input type="text" name="externalLinks" size="45" class="form" /><br />
          <input type="submit" value="Post!" class="submit" />
         </div>
        </form>As far as I can tell, it should work, and it doesn't throw any errors (in fact it shows the success message rather than the configured error page), but when I check the blogEntry table from the MySQL prompt, it responds with "Empty set".
    I've double checked to ensure that the table columns are present in MySQL and all the naming conventions line up and they do, so I figure it's my servlet that's broken.
    Advice? Ideas?
    Thanks in advance.
    Edited by: -Antonio on Apr 25, 2008 8:03 PM with additional info

    Okay, I changed a few things in the servlet code.
    For one, I'm trying a PreparedStatement in place of Statement. Don't ask me what made me think it would work any better, it just stores the sql query in cache, but I thought I'd just try something else.
    One thing this is allowing me to do is make the connection and statement (now PreparedStatement pStmt) objects local variables. It wouldn't allow me to do so before without giving me compile errors.
    package projectEgress.web.blog;
    import java.io.*;
    import java.text.*;
    import java.sql.*;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.*;
    public final class blogInput {
         /* bean properties */
        private String blogHeader;
        private String blogSubheader;
        private String blogBody;
        private String externalLinks;
            /* getters & setters */
            public String getBlogHeader() {
                return blogHeader;
            public void setBlogHeader(String blogHeader) {
                this.blogHeader = blogHeader;
            public String getBlogSubheader() {
                return blogSubheader;
            public void setBlogSubheader(String blogSubheader) {
                this.blogSubheader = blogSubheader;
            public String getBlogBody() {
                return blogBody;
            public void setBlogBody(String blogBody) {
                this.blogBody = blogBody;
            public String getExternalLinks() {
                return externalLinks;
            public void setExternalLinks(String externalLinks) {
                this.externalLinks = externalLinks;
            /* like it says, a void which writes to the database */
            public synchronized void writeToDatabase() {
                Connection conn = null;
                PreparedStatement pStmt = null;
                /* create the query string to fill the table */
                String Query = "INSERT INTO blogEntry (blogHeader, blogSubheader, blogBody, externalLinks) VALUES (\"" + this.blogHeader + "\", \"" + this.blogSubheader + "\", \"" + this.blogBody + "\", \""  + this.externalLinks + "\")";
                try {
                    /*establish the datasource and make the connection */
                    Context ctxt =  new InitialContext();
                    DataSource dsrc = (DataSource)ctxt.lookup("java:comp/env/jdbc/projectEgress");
                    conn = dsrc.getConnection();
                    pStmt = conn.prepareStatement(Query);
                    /* Add data to table 'blogEntry' in our database */
                    pStmt.executeUpdate();
                    pStmt.clearParameters();
                    /* close the connections */
                    pStmt.close();
                    conn.close();
                    /* check for exceptions, ensure connections are closed */
                    } catch (SQLException sqlx) {
                        sqlx.printStackTrace();
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    } finally {
                        if (pStmt != null) {
                            try {
                                pStmt.close();
                        } catch (SQLException sqlx) {}
                        if (conn != null) {
                            try {
                                conn.close();
                        } catch (SQLException sqlx) {}
    }Someone out there has to have a thought on this.
    Even if it's just something they think probably won't work, so long as it gives me another angle to see this from.

  • Out of Memory Error when writing from mySQL to JPanel

    Hi,
    I have a JPanel with BoxLayout to which I am adding JCheckBoxes, which are the result of an Select query to mySQL.
    My select query is giving me 15000 lines of result, in which case my program is screwed up, and I am getting OutofMemory Error.
    Does somebody know how to fix this problem?
    This is my code for the JPanel :
    srchRP = new JPanel();
         BoxLayout bl = new BoxLayout(srchRP, BoxLayout.Y_AXIS);
         srchRP.setLayout(bl);
         srchSP = new JScrollPane(srchRP);
         srchSP.setPreferredSize(new Dimension(300,470));

    If I understand correctly, your JVM simply cannot deal with 15,000 objects (the result set generated by your query). You can either make more memory available to the JVM as described above, or you can consider redesigning your application.
    It seems what you are trying to do is get every record in the database table, and display those records in a JPanel, allowing the end user to select which records he wants to perform an action on (such as delete).
    Instead of using a "select * from table" query, you could do a "select id, title from table" type of query, in which case, your data object will be a lot smaller and still give the user enough information to decide whether to delete the record or not.
    Alternatively, you could write a utility program to get the information you need from a text file generated as a result of a database dump and load that information upon startup, i.e., cache the master list of records.
    But, it seems to me, if I were your customer, I would not want to scroll through a list of 15,000 entries and deciding which ones I wanted to check off. If you figure out an easier way to manage 15,000+ records, such as allowing the user to narrow down his criteria, then you go a long way towards optimizing your code to reduce memory requirements.

Maybe you are looking for

  • SAP 8.8 Crystal Report layout templates

    I have installed SAP 8.8 this is working fine apart from one thing i don't understand..  maybe i am just being stupid.. But there are no Crystal report layouts in the system.  Do we have to download these.. surely we don't have to write them all from

  • Noob needs help with site creation -- interactive?

    I want to make a site where people can post and/or reply to other posts. I've used iWeb for a couple years so I'm good with "static" sites but how can I make one where people can post to the site themselves? For example, I write ::"what is your favor

  • Canon XF 305 Media

    It appears that support has been cut off from the Canon XF series cameras. In FCP 7 its no problem to Log and Transfer footage from the CF Cards they use in NATIVE format, so I dont have to worry about transcoding..just have to copy my files over. No

  • Business Packages available

    I would like to know if there's an extensive list of SAP Business Packages for different modules of SAP (like FI, CO, MM, SRM etc.) published somewhere. For example, business packages in FI (Finance), CO (Costing) and so forth that can be deployed in

  • .mov export problems

    Hello, I have a new WinXP computer with CS3 Master Collection and Quicktime 7.2. When I export a movie (file > Export Movie) the progress bar moves all the way to the end and hangs there. I never get my completed file. I can see a .dat file, but the