Problem updating mySQL database

I am trying to update some data in one of my tables called topic in my SQL database. I have the follwing code which gets data from a bean and updates it in the database but it does not seem to work. I do not get an exception but it will not update the record even though the bean displays the correct information about the update it does not seem to update the database, Does anyone have any idea where i am going wrong?
String updateTopic__topicID = null;
if (request.getParameter("topicID") != null) {
    updateTopic__topicID = (String)request.getParameter("topicID");
String insertTopic__username = null;
if (session.getValue("MM_Username") != null) {
    insertTopic__username = (String)session.getValue("MM_Username");
Driver DriverupdateTopic   = (Driver)Class.forName(MM_connQuestion_DRIVER).newInstance();
Connection ConnupdateTopic = DriverManager.getConnection(MM_connQuestion_STRING, MM_connQuestion_USERNAME,
                                                         MM_connQuestion_PASSWORD);
PreparedStatement updateTopic =
                      ConnupdateTopic.prepareStatement("UPDATE Question.topic  SET Topic_Name = '" + topicData.topicName
                                                           + "', Description = '" + topicData.topicDescription
                                                           + "'  WHERE Topic_ID = '" + updateTopic__topicID + "' ");
updateTopic.executeUpdate();

I tried to check it and it did not update any records
cos i got this.
Records updated: 0
The WHERE claus does match my database record because
it is called Topic_ID which is the primary key for
that table. could it be something that is wrong with
my database?
Sir,
That is unlikely.
What is more likely is that something is wrong with your code somewhere.
I am somewhat suspicious of the STRING nature of Topic_ID. That is an auto_incrementing field I think? If so try setInt or setLong.
And to answer the followup question to that.
int anintvalue = Integer.parseInt(astringvalue);The other possibility is that in your form or whatever the value of the Topic_ID is getting mucked up. I would check to make sure you have the value you think.
Finally always make sure you are talking to the database you think you are. I realize this seems stupid but in testing environments these things do happen more often then one might suppose.
Sincerely,
Slappy

Similar Messages

  • Problem viewing/updating MySQL-database with utf-8 charset

    System specs:
    Tomcat 5.5.4
    JDK1.5.0
    MySQL 4.1
    Connector/J 3.0.16
    JSTL 1.1
    I am trying to build a guestbook web-app, and want to be able to store swedish characters (available in latin1) and decided to give utf-8 a go since it would support other languages as well. I use a <Resource> in my context-xml to get the connection.
    This simply will not work; when I use the <%@ page contentType="text/html; charset=utf-8"%> declaration, the swedish characters in the raw html-code gets replaced by questionmarks. Select-queries output look ok though, as long as they don't contain the character '�'
    When removing the page-declaration, the queries show only questionmarks where swedish characters should be.
    The same goes for updating my database. Swedish characters get garbled.
    I have tried the following without success:
    *adding &useUnicode=true&characterEncoding=UTF-8 to the Resource-url -- causes my web-app to fail loading.
    *adding a <filter> to the web-apps web.xml as suggested at  http://www.javaworld.com/javaworld/jw-09-2004/jw-0906-unicode_p.html -- caused another web-app error, resulting in it not being loaded.
    *setting the form attribute accept-charset -- resulted in no improvement.
    Right now I'm half desperate and half fed-up. Is this a common problem with MySQL? Should I use another database? Or perhaps it is the Connector/J Driver that's messing things up.
    I'll appreciate any help I get greatly.

    Hello. Maybe not so interesting after a year to try to ask did you ever get a final solution to that problem in command line perspective. OR does somebody else knows solution to this problem.
    Anyway I have similar problem, I use mysql5 with latin1 charset and I can insert to my database letters ��� normally via mysql command line and they show perfectly. But the problem is my web application.
    I can insert all characters to database and retrieve them normally via web app but if i need to use mysql command line for queries it fails because those special letters appear something like ��. I still need to make queries on mysql command line as admin. I have also tried to change different drivers like
    Class.forName("org.gjt.mm.mysql.Driver"); or
    com.mysql.jdbc.Driver etc connector is 3.0.17
    I have also tried to change to utf-8 and then changed mysql def.enc to same... i have used request.setWHATEVER CHARSET.....i'm out of ideas... help?

  • Strange problem with MySQL database

    Hello,
    I'm totally puzzled by a strange error occurring with PHP/MySQL on my website... I hope someone has got an idea of what's going on and can let me know.
    In short, I have a MySQL database set up on the remote server where the website is hosted. Some pages of my website access this database with PHP.
    If the website is viewed with a browser in Windows (Firefox), it works well, the database data appear on the pages.
    If the website is viewed with a browser on Mac OS (Firefox, Safari), it doesn't work: the database isn't accessed, I get no error, just everything on the page below my PHP code is missing.
    I've attached two screenshots to show this. The website URL is: http://www.cerc.co.uk/CERC/v02/
    The pages were this occurs are: the home page (index.php and alternative index2.php), the Abous us/News page and the About us/News/Archives page.
    I really don't get where my mistake is. I would like to keep the remote server connexion details outside the root folder, but I guess that if there is no solution to this problem, then I'll have to move it back (I think it might have worked like that).
    Thanks in advance for any comment,
    Emilie
    More details
    I'm using DW CS4 on Windows XP emulated via VMware on Mac OS 10.5 (don't ask why, I wasn't given any choice). I've set up a localhost server on XP via XAMP and the news database is also there.
    Because I'm currently flipping often between the testing server and the remote server, I quickly got fed up to change all the time the connexion mode to the database (localhost or remote server) and have to resynchronise the files each time. Hence I decided to automate a bit the way the database is connected to.
    1. These 4 HTML pages with PHP code have got the below two lines when the PHP code starts:
    $pathpfx = "../.."; // see mysqlconnexion.php
    include('assets_design/php/mysqlconnexion.php');
    2. mysqlconnexion.php (see code below) calls a "connexion" file (in PHP) depending on the value of one parameter ($conxchoice). If $conxchoice = 1, the "connexion" file on the localhost is called. If $conxchoice = 2, the "connexion" file on the remote server is called. I've stored the appropriate version of mysqlconnexion.php on the localhost and the remote server (and I have checked it a million of times, they're in the right place).
    <?php
    // This code is called by and therefore included in the code of some PHP pages,
    // independently of where the pages are located within the website folder.
    // - Connexion to local server: I couldn't get the function include_once to work
    //   with a relative path, hence the use of an absolute path.
    // - Connexion to host server: I couldn't get the function include_once to work
    //   with an absolute path, hence the use of a relative path. This leads to the
    //   following problem: the path of conxsrv.php needs to be adapted to the
    //   position of the calling PHP page within the website, in order for
    //   conxsrv.php to be found on the server (it is located outside the website
    //   root folder). The variable $pathpfx is used for this purpose.
    $conxchoice = 2; // connect to 1 = testing server, 2 = host server
    // Connexion to database
    if ( $conxchoice == 1 )
    { include_once('C:\xampp\htdocs\CERC\assets_testing_server_only\conxloc.php'); }
    if ( $conxchoice == 2 )
    { include_once("$pathpfx/cgi-bin/sqlconx/conxsrv.php"); }
    ?>
    I would guess that a first hint of solution lies in the comment block, but I've really tried everything I could think of to work with relative path/absolute path respectively, unsuccessfully.
    3. The "connexion" file looks like:
    <?php
    # FileName="Connection_php_mysql.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_conx = "aaa";
    $database_conx = "bbb";
    $username_conx = "ccc";
    $password_conx = "ddd";
    $conx = mysql_pconnect($hostname_conx, $username_conx, $password_conx) or trigger_error(mysql_error(),E_USER_ERROR);
    ?>
    With aaa, bbb, ccc and ddd the appropriate value depending on the file. The # lines were introduced by DW when these files were created (I've then changed the variable names and moved the files to another place).
    Screenshots

    Well, my question has actually not been answered yet but the problem, as strangely as it appeared, has now disappeared. Best but scariest of all, I didn't do anything. Weird.
    Hope it never comes back,
    Emilie

  • Problem with Mysql DataBase

    hi all,
    I am new to this topic,so could any one please help me on this problem.
    How to Connect MySQL database with java ,
    I am getting errors with Driver and data source.
    which ODBC data source (user DSN,system DSN or file DSN ....)
    So please help me how to set the driver settings and how to connect it.
    If you have any example ....
    please post it
    thanks...

    sorry! this is the right one..
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    public class MYSQL
    Class.forName("org.gjt.mm.mysql.Driver");
    String url = "jdbc:mysql:databaseName";
    Connection con = DriverManager.getConnection (url, "loginID", "password");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT * from javatest");
    while(rs.next()) {
    int pid = rs.getInt(1);
    String name = rs.getString(2);
    String address = rs.getString(3);
    String city = rs.getString(4);
    String state = rs.getString(5);
    String zip = rs.getString(6);
    String email = rs.getString(7);

  • Problem Seeing MySQL Database

    I am trying to migrate a MySQL 5 database to Oracle. Using these forums, I successfully resolved my connections problems, but now I have a new issue. When trying to capture my database, the capture screen connects to the server and then gives me a list of databases that I can capture. The problem is that it only lists the "test" database, not the "mysql" database where the data is.
    Any ideas why it does not see all the databases?

    the user root must have
    mysql>grant all on *.* on root;
    How did you get run the mysql 5 plugin?
    I just see plugin for mysql v 3 and 4.
    Thanks
    Murcia

  • Problems updating a database

    i'm developing in jsp, an intranet that runs on Weblogic Server
    5.1, but it seems something is wrong with the oracle, one user
    updates the data in one machine, and does not see the changes
    inmediatly, he has to reload the page in order to see it, so
    while i get into the same page, i do see the changes, what can be
    wrong, i'm using Oracle 8.0.6, i know that the JDBC drivers are
    set up with autocommit, so i don't have to send a commit to the
    database, i think is a problem with the oracle server
    configuration, can someone pls help me?, thanks in advance
    regards

    You HAVE to commit programatically(like conn.commit()...) before
    getting out of that method. and i have a confusion whether
    generally by default the i know that the JDBC drivers are
    set up with autocommit as false. i think its the other way round.
    Thanks.
    Arnab

  • Problem accessing mysql database

    Hello all
    I am using the following piece of code to access a database running remotely..I am using mysql-connector-java-3.1.0.
    Connection C = DriverManager.getConnection(
    "jdbc:mysql://***.***.***.***:3306/db1?user=\'******\'&password=\'*****\'");
    In the above ***.***.***.*** is the ip address of the machine on which the database is there.
    The error message is:
    Invalid authorization specification: Access denied for user.
    Please help me out on this. This is my first attempt to connect to MySQL from Java. Any code or comments and suggestions will be great.
    thanks a bunch
    Mahesh :)

    hi
    thanks a lot for ur reply...I had enuf rights to connect to the database....i recollected later that the right way to get the Connection object is like this:
    Connection C = DriverManager.getConnection("jdbc:mysql://***.***.***.***:3306/db1?user=******&password=*****");
    The name-value pairs like name and password need not have inverted commas...just user=soandso@password=soandso...
    thanks a lot nyways...
    Mahesh :)

  • Problems updating JDBC database

    Please someone help me with my connection to MSAccess database. If it is possible, email me to [email protected]
    1.
    connection.getMetaData().
    supportsResultSetConcurrency( ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE)=true !!!
    2.
    stmt=database.createStatement(
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    OK.
    3.
    stmt.executeUpdate("DELETE FROM "+tblName);
    rset=stmt.executeQuery("SELECT * FROM "+tblName);
    ERROR. Why?

    I have heard that there are JDBC drivers that will throw an error if you try to select from an empty table. But it would help to know what error you are getting. And what driver you are using.

  • Error in Mysql database connectivity

    hello,
    there is problem in Mysql database connectivity.
    when i connect JSP program to Mysql database it gives error :
    Server configuration denied access to data source
    please help me asap
    kuldip jain
    [email protected]

    i m also working on Mysql Java but on Window 2000 platform
    here is the Java code which successfully runing on my machine
    import java.sql.*;
    public class TestMySql
         public static void main(String[] Args)
              try
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    Connection C = DriverManager.getConnection(
    "jdbc:mysql://server2:3306/Db?user=root");
    Statement Stmt = C.createStatement();
    ResultSet RS = Stmt.executeQuery("SELECT * from T1");
    while (RS.next()) {
                             System.out.println(RS.getString(1));
    catch (Exception E)
    System.out.println("SQLException: " + E.getMessage());

  • Problem connecting a webservice to a mysql database

    Hi,
    I am trying to connect a webservice to a mysql database. I am using sun application server 8.1 and Mysql 4.1.
    I have been using the application servers examples to achieve my goals thus far. I have made the following progress.
    - I have got a simple jdbc web application on the application server to access my mysql database.
    - I have got a web service on the application server to work properly, in regards to performing a simple rpc method such as 'sayHello'.
    - I now want my webservice to have similar functionality to the jdbc application. A simple query or update to the database installed on the application server invoked from the webservice deployed on the application server.
    I have been having difficulty in achieveing this. I don't understand why I can't get this to work as i can achieve access to the database from the jdbc app. I am getting the following errors on the application server log:
    [#|2005-03-01T14:22:59.739+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    retrieving_initial_context...|#]
    [#|2005-03-01T14:22:59.789+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    retrieved_initial_context_successfully|#]
    [#|2005-03-01T14:22:59.789+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    recording_the_greeting...|#]
    [#|2005-03-01T14:22:59.789+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    getting_datasource...|#]
    [#|2005-03-01T14:22:59.799+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    got_datasource_successfully|#]
    [#|2005-03-01T14:22:59.799+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    getting_connection...|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    got_connection_successfully|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    getting_statement...|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    got_statement_successfully|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    executing_query...|#]
    [#|2005-03-01T14:22:59.900+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    could_not_interact_with_db|#]
    [#|2005-03-01T14:22:59.910+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    excpetion: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.io.IOException
    MESSAGE: An established connection was aborted by the software in your host machine
    STACKTRACE:
    java.io.IOException: An established connection was aborted by the software in your host machine
    at sun.nio.ch.SocketDispatcher.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:25)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
    at sun.nio.ch.IOUtil.read(IOUtil.java:206)
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:207)
    at com.sun.enterprise.server.ss.ASInputStream.read(ASInputStream.java:75)
    at com.sun.enterprise.server.ss.ASInputStream.read(ASInputStream.java:66)
    at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:75)
    at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(Re adAheadInputStream.java:94)
    at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:122)
    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1842)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2292)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2788)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1625)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:2291)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:2226)
    at com.mysql.jdbc.Statement.executeQuery(Statement.java:1159)
    at goodbyeservice.GoodbyeImpl.sayGoodbye(Unknown Source)
    at goodbyeservice.GoodbyeIF_Tie.invoke_sayGoodbye(GoodbyeIF_Tie.java:54)
    at goodbyeservice.GoodbyeIF_Tie.processingHook(GoodbyeIF_Tie.java:124)
    at com.sun.xml.rpc.server.StreamingHandler.handle(StreamingHandler.java:321)
    at com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doPost(JAXRPCServletDelegate. java:443)
    at com.sun.enterprise.webservice.JAXRPCServlet.doPost(JAXRPCServlet.java:50)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFil terChain.java:257)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterCha in.java:55)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.ja va:161)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain .java:157)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java: 263)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextVal ve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java: 173)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:13 2)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:184)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.ja va:653)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.ja va:534)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doTask(ProcessorTask.jav a:403)
    at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:55)
    ** END NESTED EXCEPTION **
    I can't think of what the problem may be other then the following issues:
    - the mysql database would allow access from the jdbc application as it is seen as a local process whereas it may not for the webservice as it is seen as a remote process???
    - I may need to utilize a different datasource class to give the webservice access rights?
    Any help or advice in how this problem might be resolved or even just what it is would help me greatly. Thanks for you time in advance.
    Alvee

    Hi,
    I am trying to connect a webservice to a mysql database. I am using sun application server 8.1 and Mysql 4.1.
    I have been using the application servers examples to achieve my goals thus far. I have made the following progress.
    - I have got a simple jdbc web application on the application server to access my mysql database.
    - I have got a web service on the application server to work properly, in regards to performing a simple rpc method such as 'sayHello'.
    - I now want my webservice to have similar functionality to the jdbc application. A simple query or update to the database installed on the application server invoked from the webservice deployed on the application server.
    I have been having difficulty in achieveing this. I don't understand why I can't get this to work as i can achieve access to the database from the jdbc app. I am getting the following errors on the application server log:
    [#|2005-03-01T14:22:59.739+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    retrieving_initial_context...|#]
    [#|2005-03-01T14:22:59.789+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    retrieved_initial_context_successfully|#]
    [#|2005-03-01T14:22:59.789+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    recording_the_greeting...|#]
    [#|2005-03-01T14:22:59.789+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    getting_datasource...|#]
    [#|2005-03-01T14:22:59.799+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    got_datasource_successfully|#]
    [#|2005-03-01T14:22:59.799+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    getting_connection...|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    got_connection_successfully|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    getting_statement...|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    got_statement_successfully|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    executing_query...|#]
    [#|2005-03-01T14:22:59.900+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    could_not_interact_with_db|#]
    [#|2005-03-01T14:22:59.910+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    excpetion: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.io.IOException
    MESSAGE: An established connection was aborted by the software in your host machine
    STACKTRACE:
    java.io.IOException: An established connection was aborted by the software in your host machine
    at sun.nio.ch.SocketDispatcher.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:25)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
    at sun.nio.ch.IOUtil.read(IOUtil.java:206)
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:207)
    at com.sun.enterprise.server.ss.ASInputStream.read(ASInputStream.java:75)
    at com.sun.enterprise.server.ss.ASInputStream.read(ASInputStream.java:66)
    at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:75)
    at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(Re adAheadInputStream.java:94)
    at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:122)
    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1842)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2292)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2788)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1625)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:2291)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:2226)
    at com.mysql.jdbc.Statement.executeQuery(Statement.java:1159)
    at goodbyeservice.GoodbyeImpl.sayGoodbye(Unknown Source)
    at goodbyeservice.GoodbyeIF_Tie.invoke_sayGoodbye(GoodbyeIF_Tie.java:54)
    at goodbyeservice.GoodbyeIF_Tie.processingHook(GoodbyeIF_Tie.java:124)
    at com.sun.xml.rpc.server.StreamingHandler.handle(StreamingHandler.java:321)
    at com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doPost(JAXRPCServletDelegate. java:443)
    at com.sun.enterprise.webservice.JAXRPCServlet.doPost(JAXRPCServlet.java:50)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFil terChain.java:257)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterCha in.java:55)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.ja va:161)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain .java:157)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java: 263)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextVal ve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java: 173)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:13 2)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:184)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.ja va:653)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.ja va:534)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doTask(ProcessorTask.jav a:403)
    at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:55)
    ** END NESTED EXCEPTION **
    I can't think of what the problem may be other then the following issues:
    - the mysql database would allow access from the jdbc application as it is seen as a local process whereas it may not for the webservice as it is seen as a remote process???
    - I may need to utilize a different datasource class to give the webservice access rights?
    Any help or advice in how this problem might be resolved or even just what it is would help me greatly. Thanks for you time in advance.
    Alvee

  • Problems connectig my webservice to my mysql database.

    Hi,
    I am trying to connect a webservice to a mysql database. I am using sun application server 8.1 and Mysql 4.1.
    I have been using the application servers examples to achieve my goals thus far. I have made the following progress.
    - I have got a simple jdbc web application on the application server to access my mysql database.
    - I have got a web service on the application server to work properly, in regards to performing a simple rpc method such as 'sayHello'.
    - I now want my webservice to have similar functionality to the jdbc application. A simple query or update to the database installed on the application server invoked from the webservice deployed on the application server.
    I have been having difficulty in achieveing this. I don't understand why I can't get this to work as i can achieve access to the database from the jdbc app. I am getting the following errors on the application server log:
    [#|2005-03-01T14:22:59.739+0000|INFO|sun-appserver-pe8.1|javax.enterprise.system.stream.out|_ThreadID=16;|
    retrieving_initial_context...|#]
    [#|2005-03-01T14:22:59.789+0000|INFO|sun-appserver-pe8.1|javax.enterprise.system.stream.out|_ThreadID=16;|
    retrieved_initial_context_successfully|#]
    [#|2005-03-01T14:22:59.789+0000|INFO|sun-appserver-pe8.1|javax.enterprise.system.stream.out|_ThreadID=16;|
    recording_the_greeting...|#]
    [#|2005-03-01T14:22:59.789+0000|INFO|sun-appserver-pe8.1|javax.enterprise.system.stream.out|_ThreadID=16;|
    getting_datasource...|#]
    [#|2005-03-01T14:22:59.799+0000|INFO|sun-appserver-pe8.1|javax.enterprise.system.stream.out|_ThreadID=16;|
    got_datasource_successfully|#]
    [#|2005-03-01T14:22:59.799+0000|INFO|sun-appserver-pe8.1|javax.enterprise.system.stream.out|_ThreadID=16;|
    getting_connection...|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.system.stream.out|_ThreadID=16;|
    got_connection_successfully|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.system.stream.out|_ThreadID=16;|
    getting_statement...|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.system.stream.out|_ThreadID=16;|
    got_statement_successfully|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.system.stream.out|_ThreadID=16;|
    executing_query...|#]
    [#|2005-03-01T14:22:59.900+0000|INFO|sun-appserver-pe8.1|javax.enterprise.system.stream.out|_ThreadID=16;|
    could_not_interact_with_db|#]
    [#|2005-03-01T14:22:59.910+0000|INFO|sun-appserver-pe8.1|javax.enterprise.system.stream.out|_ThreadID=16;|
    excpetion: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.io.IOException
    MESSAGE: An established connection was aborted by the software in your host machine
    STACKTRACE:
    java.io.IOException: An established connection was aborted by the software in your host machine
         at sun.nio.ch.SocketDispatcher.read0(Native Method)
         at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:25)
         at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
         at sun.nio.ch.IOUtil.read(IOUtil.java:206)
         at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:207)
         at com.sun.enterprise.server.ss.ASInputStream.read(ASInputStream.java:75)
         at com.sun.enterprise.server.ss.ASInputStream.read(ASInputStream.java:66)
         at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:75)
         at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:94)
         at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:122)
         at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1842)
         at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2292)
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2788)
         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1625)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:2291)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:2226)
         at com.mysql.jdbc.Statement.executeQuery(Statement.java:1159)
         at goodbyeservice.GoodbyeImpl.sayGoodbye(Unknown Source)
         at goodbyeservice.GoodbyeIF_Tie.invoke_sayGoodbye(GoodbyeIF_Tie.java:54)
         at goodbyeservice.GoodbyeIF_Tie.processingHook(GoodbyeIF_Tie.java:124)
         at com.sun.xml.rpc.server.StreamingHandler.handle(StreamingHandler.java:321)
         at com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doPost(JAXRPCServletDelegate.java:443)
         at com.sun.enterprise.webservice.JAXRPCServlet.doPost(JAXRPCServlet.java:50)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
         at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
         at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
         at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
         at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:184)
         at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:653)
         at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:534)
         at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doTask(ProcessorTask.java:403)
         at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:55)
    ** END NESTED EXCEPTION **
    I can't think of what the problem may be other then the following issues:
    - the mysql database would allow access from the jdbc application as it is seen as a local process whereas it may not for the webservice as it is seen as a remote process???
    - I may need to utilize a different datasource class to give the webservice access rights?
    Any help or advice in how this problem might be resolved or even just what it is would help me greatly. Thanks for you time in advance.
    Alvee

    I am getting this problem from java nio server to java nio client. I get it intermittently on windows. Have not tried other os's. It almost seems like some kind of race condition as my unit test case was passing for the past few weeks and when i changed some code today, it started failing intermittently with this error.
    IOException: An established connection was aborted by the software in your host machine

  • Problem connecting my webservice to mysql database

    Hi,
    I am trying to connect a webservice to a mysql database. I am using sun application server 8.1 and Mysql 4.1.
    I have been using the application servers examples to achieve my goals thus far. I have made the following progress.
    - I have got a simple jdbc web application on the application server to access my mysql database.
    - I have got a web service on the application server to work properly, in regards to performing a simple rpc method such as 'sayHello'.
    - I now want my webservice to have similar functionality to the jdbc application. A simple query or update to the database installed on the application server invoked from the webservice deployed on the application server.
    I have been having difficulty in achieveing this. I don't understand why I can't get this to work as i can achieve access to the database from the jdbc app. I am getting the following errors on the application server log:
    [#|2005-03-01T14:22:59.739+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    retrieving_initial_context...|#]
    [#|2005-03-01T14:22:59.789+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    retrieved_initial_context_successfully|#]
    [#|2005-03-01T14:22:59.789+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    recording_the_greeting...|#]
    [#|2005-03-01T14:22:59.789+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    getting_datasource...|#]
    [#|2005-03-01T14:22:59.799+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    got_datasource_successfully|#]
    [#|2005-03-01T14:22:59.799+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    getting_connection...|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    got_connection_successfully|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    getting_statement...|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    got_statement_successfully|#]
    [#|2005-03-01T14:22:59.819+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    executing_query...|#]
    [#|2005-03-01T14:22:59.900+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    could_not_interact_with_db|#]
    [#|2005-03-01T14:22:59.910+0000|INFO|sun-appserver-pe8.1|javax.enterprise.syste m.stream.out|_ThreadID=16;|
    excpetion: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.io.IOException
    MESSAGE: An established connection was aborted by the software in your host machine
    STACKTRACE:
    java.io.IOException: An established connection was aborted by the software in your host machine
    at sun.nio.ch.SocketDispatcher.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:25)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
    at sun.nio.ch.IOUtil.read(IOUtil.java:206)
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:207)
    at com.sun.enterprise.server.ss.ASInputStream.read(ASInputStream.java:75)
    at com.sun.enterprise.server.ss.ASInputStream.read(ASInputStream.java:66)
    at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:75)
    at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(Re adAheadInputStream.java:94)
    at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:122)
    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1842)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2292)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2788)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1534)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1625)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:2291)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:2226)
    at com.mysql.jdbc.Statement.executeQuery(Statement.java:1159)
    at goodbyeservice.GoodbyeImpl.sayGoodbye(Unknown Source)
    at goodbyeservice.GoodbyeIF_Tie.invoke_sayGoodbye(GoodbyeIF_Tie.java:54)
    at goodbyeservice.GoodbyeIF_Tie.processingHook(GoodbyeIF_Tie.java:124)
    at com.sun.xml.rpc.server.StreamingHandler.handle(StreamingHandler.java:321)
    at com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doPost(JAXRPCServletDelegate. java:443)
    at com.sun.enterprise.webservice.JAXRPCServlet.doPost(JAXRPCServlet.java:50)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFil terChain.java:257)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterCha in.java:55)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.ja va:161)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain .java:157)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java: 263)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextVal ve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java: 173)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:13 2)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:184)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.ja va:653)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.ja va:534)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doTask(ProcessorTask.jav a:403)
    at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:55)
    ** END NESTED EXCEPTION **
    I can't think of what the problem may be other then the following issues:
    - the mysql database would allow access from the jdbc application as it is seen as a local process whereas it may not for the webservice as it is seen as a remote process???
    - I may need to utilize a different datasource class to give the webservice access rights?
    Any help or advice in how this problem might be resolved or even just what it is would help me greatly. Thanks for you time in advance.
    Alvee

    The driver is in right place
    Originally I placed him in wrong directory and got an error, indicationg, that Driver class is not found, but then I corrected it, The problem is in connection to database - it doesn't work.
    I tired to load the same driver into Netbeans and could easyli create a connection to database, but I get it not working ander Sun Application server

  • Update command overwrites 1st record in mysql database

    hi
    I'm having a bit of a problem with a form I created in livecycle designer.
    I have connected the form to a MySQL database.
    whenever I try to update a record , retrieved via navigation buttons or search box, the 1st record in the mysql database is overwritten.
    I'm using the xfa.sourceSet.DataConnection.update() with and an click event
    I have my Stay BOF and Stay EOF set on the data connections.
    I'm not sure what I am doing wrong.
    The forms Data connections are using sql select query because the table in the database has an auto incrementing column.
    any suggestions you guys provide will be appreciated.

    Guys, I am still racking my brain. I have taken some screenshots to show you how I have my database tables set up. I was able to get the tables over to the InnoDB type so I can make foreign keys. Here is how I currently have them setup, can someone check this out and see if it's correct?
    Table 1 (carinfo)
    Table 2 (images)
    Thanks

  • Update Specific Rows In MySQL Database?

    greetings all
    i have MySQL database named library contains a table named books with the attributes:name,amount,price,cat_id
    and i want to update all the names,amount,prices for specific cat_id
    so i used the following query:
    PreparedStatement ps = connection.prepareStatement("UPDATE books SET name = ?,amount = ?,price = ? Where cat_id = "+1);
    and get the question marked values from the JTable named table_science
                    for(int i = 0 ; i< dtm_science.getRowCount(); i++){                                         ps.setString(1,(String)table_science.getValueAt(i,2));                                  ps.setInt(2,(Integer)table_science.getValueAt(i,1));                 ps.setInt(3,(Integer)table_science.getValueAt(i,0));                                 ps.executeUpdate();                                                                                                                        }                         ps.close();             connection.close();
    the code doesn't work properly
    it takes the values in the last row in the jtable and set them for all attributes with cat_id=1
    meaning if you have 3 rows in the jtable named table_science which have cat_id=1 and the columns:
    name,amount,price
    abc,5,300
    efg,6,400
    mno,6,900
    and when i exceute the update query all the fields in the database which have cat_id=1 would be set to mno,6,900
    meaning that the table_science would be:
    mno,6,900
    mno,6,900
    mno,6,900
    is there's an error in the code?
    or what's the problem?
    thanks in advance

    the database name:test
    table name:books
    attributes:name,amount,price,cat_id
    description:several names may have the same cat_id
    goal:when the user presses update button
    all names,amounts,prices with cat_id=1 in the database is updated with the JTable values name,amount,price
    problem:when changing values in the JTable and trying to update all names,amounts,prices with cat_id=1 is set to the last row values in the jtable?
    here's the whole code:
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.Dimension;
    import java.awt.*;
    import javax.swing.JFrame;
    import java.awt.event.*;
    import javax.swing.JTable;
    import java.sql.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSetMetaData;
    import java.sql.ResultSet;
    import java.sql.Statement;
    class table_update extends JPanel {
        static DefaultTableModel dtm1;
        static JTable table1;
        static JFrame frame;
        public table_update() {
            super(new GridLayout(1, 1));
            dtm1 = new DefaultTableModel();
            dtm1.addColumn("ID");
            dtm1.addColumn("Name");
            dtm1.addColumn("Amount");
            dtm1.addColumn("Price");
            table1 = new JTable(dtm1) {
                public Class getColumnClass(int column) {
                    return getValueAt(0, column).getClass();
            JScrollPane scrollPane1 = new JScrollPane(table1);
            JButton Update = new JButton("Update");
            table1.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            table1.setPreferredScrollableViewportSize(new Dimension(410, 160));
            JPanel panel1 = new JPanel(new FlowLayout());
            panel1.add(scrollPane1);
            panel1.add(Update);
            Update.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent event20) {
                    update_db();
                    frame.dispose();
                    createAndShowGUI();
            //reading from databse
            try {
                Class.forName("com.mysql.jdbc.Driver");
                Connection c1 = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "");
                Statement s1 = c1.createStatement();
                ResultSet rs1 = s1.executeQuery("SELECT name,amount,price from books where cat_id=1");
                int id1 = 0;
                while (rs1.next()) {
                    id1++;
                    Object[] obj = {id1, rs1.getString("name"), rs1.getInt("amount"), rs1.getInt("price")};
                    dtm1.addRow(obj);
                c1.close();
            } catch (Exception e) {
                e.printStackTrace();
            table1.setModel(dtm1);
            setLayout(new BorderLayout());
            add(panel1, BorderLayout.CENTER);
        public static void createAndShowGUI() {
            frame = new JFrame("Update DB");
            frame.setSize(500, 300);
            frame.setLocationRelativeTo(null);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(new table_update());
            frame.setResizable(false);
            frame.setVisible(true);
            JTable table1 = new JTable();
            table1.setModel(new DefaultTableModel(new Object[][][][]{}, new String[]{"id", "name", "amount", "price"}) {
                Class[] types = new Class[]{
                    java.lang.Integer.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class
                public Class getColumnClass(int columnIndex) {
                    return types[columnIndex];
        public static void update_db() {
            Connection c = null;
            PreparedStatement ps = null;
            try {
                Class.forName("com.mysql.jdbc.Driver");
                String url = "jdbc:mysql://localhost:3306/test?requireSSL=false&useUnicode=true&characterEncoding=utf8";
                c = DriverManager.getConnection(url, "root", "");
                ps = c.prepareStatement("UPDATE books SET name = ?,amount = ?,price = ? WHERE cat_id = 1 ");
                for (int i = 0; i < dtm1.getRowCount(); i++) {
                    ps.setString(1, (String) table1.getValueAt(i, 1));
                    ps.setInt(2, (Integer) table1.getValueAt(i, 2));
                    ps.setInt(3, (Integer) table1.getValueAt(i, 3));
                    ps.executeUpdate();
                ps.close();
                c.close();
            } catch (Exception ex) {
                ex.printStackTrace();
        public static void main(String[] args) {
            createAndShowGUI();
    }

  • Problems with mysql after update to php 5.3

    Hi everyone,
    I know I am not the only one having trouble with that upgrade but so far I still have some issues.
    I have read the news about the update and the wiki. I use apache, php, mysql and phpmyadmin.
    After the update, I installed php-apache, php-mcrypt and used php.ini.pacnew to do my new configuration.
    Everything works fine except mysql.
    I have a weird problem that is that I can access and do whatever I want to databases with phpmyadmin but as soon as I try to connect to the mysql database with php code then my browser tells me that the page can't be loaded and that "the connection terminated unexpectedly". What is the problem ? Am I the only one in this situation ?
    Thanks for your time !

    Here it is, that's the error log of httpd:
    [Sun Sep 27 17:25:07 2009] [notice] child pid 2006 exit signal Segmentation fault (11)
    [Sun Sep 27 19:40:32 2009] [error] [client 127.0.0.1] File does not exist: /srv/http/favicon.ico
    [Sun Sep 27 19:40:36 2009] [error] [client 127.0.0.1] File does not exist: /srv/http/favicon.ico
    [Sun Sep 27 19:40:37 2009] [error] [client 127.0.0.1] PHP Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /home/yms/projects/homepage/yms/index.php on line 60, referer: http://localhost/~yms/
    [Sun Sep 27 19:40:37 2009] [error] [client 127.0.0.1] PHP Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /home/yms/projects/homepage/yms/index.php on line 73, referer: http://localhost/~yms/
    [Sun Sep 27 19:40:37 2009] [error] [client 127.0.0.1] PHP Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /home/yms/projects/homepage/yms/index.php on line 60, referer: http://localhost/~yms/
    [Sun Sep 27 19:40:37 2009] [error] [client 127.0.0.1] PHP Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /home/yms/projects/homepage/yms/index.php on line 73, referer: http://localhost/~yms/
    [Sun Sep 27 19:40:37 2009] [error] [client 127.0.0.1] File does not exist: /srv/http/favicon.ico
    [Sun Sep 27 19:40:38 2009] [notice] child pid 2003 exit signal Segmentation fault (11)
    [Sun Sep 27 19:40:38 2009] [notice] child pid 2577 exit signal Segmentation fault (11)
    And that's the access log in case it is useful:
    127.0.0.1 - - [27/Sep/2009:19:40:32 +0200] "GET / HTTP/1.1" 200 788
    127.0.0.1 - - [27/Sep/2009:19:40:32 +0200] "GET /favicon.ico HTTP/1.1" 404 1085
    127.0.0.1 - - [27/Sep/2009:19:40:32 +0200] "GET /icons/blank.gif HTTP/1.1" 200 148
    127.0.0.1 - - [27/Sep/2009:19:40:32 +0200] "GET /icons/folder.gif HTTP/1.1" 200 225
    127.0.0.1 - - [27/Sep/2009:19:40:36 +0200] "GET /~yms HTTP/1.1" 301 368
    127.0.0.1 - - [27/Sep/2009:19:40:36 +0200] "GET /~yms/ HTTP/1.1" 200 1150
    127.0.0.1 - - [27/Sep/2009:19:40:36 +0200] "GET /favicon.ico HTTP/1.1" 404 1085
    127.0.0.1 - - [27/Sep/2009:19:40:36 +0200] "GET /icons/back.gif HTTP/1.1" 200 216
    127.0.0.1 - - [27/Sep/2009:19:40:37 +0200] "GET /favicon.ico HTTP/1.1" 404 1085
    And thanks for trying to help me ;-)

Maybe you are looking for

  • How do you use two ipods in the same itunes???

    My brother recently bought an ipod (15GB) i have been fine using my one (20GB) with my itunes on my computer. When i plug my brothers ipod in to my computer and open itunes i expect the music only about (5GB) to transfer to his ipod instead it just s

  • How to add hashes to sql querys

    The data I wish to add to mysql contains characters such as " and ' and so i get and exception when updating the database. How do I add hashes to the string so that I won't get the error: ie really "cool" becomes really /"cool/" though hashes should

  • GetInputStream problem

    I am new to JAVA and am working on a simple socket connection class to read an HTTP post. But am having a problem with it looping. The while statement doesn't seem to recognize when there is no more input. My understanding is that a null value should

  • How can I increase font when I am downloading report?

    Hello all,   I am running report ,then there is 1 button 'PDF download' through that I am downloading that report using function module 'CONVERT_ABAPSPOOLJOB_2_PDF' , But there is 1 problem it showing very small font.How can I increase that font. Aft

  • Style Elements - defining your own ?

    hi, I have a list of typography elements to define styles for - can map most to 'heading1', 'heading2', 'Portlet Header', etc. style elements in the portal style. however, to make more meaningful names for our site - e.g. 'Content Header', 'copy text