JDBC Update

I'm trying to build an Applet that will update a MySQL database. Unfortunately, I'm not sure if my Try statement is correct or if I'm using the proper SQL statements. Right now everything compiles fine and the database will be updated, but it's throwing an "Exception: NULL". I believe this results from my lack of ResultSet statement. What would the ResultSet statement be to work with this?
    public void actionPerformed(ActionEvent e) {
      if (e.getSource() == left1) {
        lscore = lscore + 1;
        l = String.valueOf(lscore);
        updateString = "UPDATE SCORE " +
        "SET SCORE = " + l + " WHERE SIDE = 1";
        try {
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          con = DriverManager.getConnection("jdbc:mysql:///bball",
                                            "root", "********");
          st = con.createStatement();
          st.executeUpdate(updateString);
          while (rs.next()) {
        catch (Exception d) {
          System.err.println("Exception: " + d.getMessage());
        finally {
          try {
            if (rs != null) {
              rs.close();
            if (st != null) {
              st.close();
            if (con != null) {
              con.close();
          catch (SQLException d) {
        fleft.setText(l);
      }notes:
-The table name is "score" and the column I'm updating is "score." Yeah, that was a kinda dumb naming convention, but it works.
-the code for the update was borrowed from a tutorial and re-hashed for my own devices. I may need to get rid of some of the statements, but I'm not sure which ones- I'm new to the JDBC stuff.

Try having a look at the Java console (configurable through the Java control panel if you're using a Sun VM) to see what error you're getting.
By default applets are only allowed to communicate with the server they are hosted on. If this is not the same as your MySQL server then this could be the cause of your problem.

Similar Messages

  • SAP XI JDBC update SQL statement

    Hi,
    I am new to JDBC to RFC configuration and is currently on a deadlock.
    We are running a real time JDBC update statement where records are created based on employee login. We have configured the sender adapter to retrieved 5 records for every 5 seconds using the SQL query below:
    select *  from dtable where  uploaded=false order by recordno asc limit 5;
    and update using:
    update dtable set uploaded=true where uploaded=false order by recordno asc limit 5;
    The problem is that when there are only 3 records retrieved in the selection, the update statement always update 5 records back. This makes records created in-between the select and update to be updated as well.
    Can anyone suggest the correct update statement? Can I use the record numbers retrieved from the first statement in the update?
    Thanks,
    Ryan

    Hi,
    >>>>Can anyone suggest the correct update statement?
    1. you have a few choices but one of them would be to use a stored procedure in the select statement (which would have both select and update statements)
    2.
    a) select *  from dtable where  uploaded=false order by recordno
    b) update dtable set uploaded=true where uploaded=false
    c) split them by 5 rows in the mapping (multimapping)
    Regards,
    Michal Krawczyk

  • Proxy to JDBC Update

    Hi Friends,
    I have a issue in proxy to JDBC update. there are onley 4 fileds to be inserted  into table..
    And before inserting the fileds into table i need to check whether the fields are there or not if not insert if they are then update,, i need to check all the four fields. for this..
    Any way to solve this kind of issue..
    Regards
    Vijay

    But what is the need of it?
    In both cases you have to perform some action on database.
    1. If records are there then Update
    2.If records are not present then Insert.
    So if even you check the records prior to sending it to database....you have to do the same(Inster or Update) and UPDATE_INSERT is possible with JDBC rec. adapter.
    Then why you need to check it? Is there any business logic behind it? Or you it was jut for practive purpose?
    Thanks
    Farooq

  • Why my JDBC UPdate hangs up??

    Hi, Sir::
    I use following simple JDBC Update program to update my table TEST,
    See following code:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    // create table test(Test_ID number, Test_Val varchar(30));
    public class Update {
      public static void main(String args[]) {
        Connection con = null;
        if (args.length != 2) {
          System.out.println("Syntax: <java UpdateApp [number] [string]>");
          return;
        try {
          String driver = "oracle.jdbc.driver.OracleDriver";
          Class.forName(driver).newInstance();
          String url = "jdbc:oracle:thin:@localhost:1521:usa";
          con = DriverManager.getConnection(url, "scott", "tiger");
          Statement s = con.createStatement();
          String test_id = args[0];
          String test_val = args[1];
          int update_count = s.executeUpdate("INSERT INTO test (test_id, test_val) "
                  + "VALUES(" + test_id + ", '" + test_val + "')");
          s.executeUpdate("UPDATE test SET TEST_VAL= 'John Alan' WHERE TEST_ID=1");
          System.out.println(update_count + " rows inserted.");
          s.close();
        } catch (Exception e) {
          e.printStackTrace();
        } finally {
          if (con != null) {
            try {
              con.close();
            } catch (SQLException e) {
              e.printStackTrace();
               When I run with command:
    C:\temp\javaCode>java Update 2 MyTest
    It hangs here and did not process, If I remove the statement:
    s.executeUpdate("UPDATE test SET TEST_VAL= 'John Alan' WHERE TEST_ID=1");
    it works and insert 1 record into Test Table.
    What is wrong here??
    How to fix it??
    Thanks
    Sunny

    Did you try with another Statement? I would try closing the first statement and creating a new one.
          Class.forName(driver).newInstance();
          String url = "jdbc:oracle:thin:@localhost:1521:usa";
          con = DriverManager.getConnection(url, "scott", "tiger");
          Statement s = con.createStatement();
          String test_id = args[0];
          String test_val = args[1];
          int update_count = s.executeUpdate("INSERT INTO test (test_id, test_val) "
                  + "VALUES(" + test_id + ", '" + test_val + "')");
           // close it and create a new one
           s.close();
           s = con.createStatement();
          s.executeUpdate("UPDATE test SET TEST_VAL= 'John Alan' WHERE TEST_ID=1");
    Let me know if it works.

  • Sender jdbc  update sql error

    hello friend ,
    my xi-content scenario is oracle -> xi ->sapr/3
    i am getting erro message in adapter monitor as following 
    Sender Adapter v0915 for Party '', Service 'oracle':
    Configured at 04:26:46 2006-04-03
    Last message processing started 05:17:12 2006-04-03
    Error: SQLException during update 'TEST': java.sql.SQLException: ORA-00900: invalid SQL statement
      last retry interval started 05:17:12 2006-04-03
      length 60,000 secs
    but update sql query  is running fine on DB. still i am getting invalid SQL statement .
    no message in sxmb_moni.
    how should i check my jdbc adapter is running fine if it fine then what is error .
    thanks friends.
    amit ranjan

    Amit,
    You are using a sender JDBC adapter. There are 2 SQL querries you write in a sender adapter(JDBC).
    1. Select querry which selects the fields and fetch it to your XI server.
    2. Update SQL. This is a crucial one coz you can not process same set of rows again and again. So you may want to maintain a flag. This happens here.
    In your case update SQL querry does not seem to work.
    Check it.
    For more help post us the 2 querries(select & update).
    Look into this link for info on config of sender JDBC adapter
    http://help.sap.com/saphelp_nw2004s/helpdata/en/ae/d03341771b4c0de10000000a1550b0/frameset.htm
    <i>(P.S: Reward replies that are helpful)</i>
    Regards,
    Jai Shankar.

  • JDBC Update Failed in JTable Interface

    A connection is established to database and the JTable gets the details from database and displays it in the form of a JTable as normal. When i edit just one cell, the update is processed successfully, however when try to update second cell on that particular table, the update would fail. It seems that the second update doesnt actually generate a SQL update statement to execute on database. If anyone has come across such a problem, could you please let me know what i am doing wrong here. I am using an instance of this class to create each JTable on my GUI:
    import javax.swing.JTable;
    import javax.swing.JScrollPane;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Vector;
    import java.sql.*;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.event.TableModelEvent;
    public class TableGen extends JFrame {
    public JTable table1;
    public JScrollPane scrollPane;
    private boolean DEBUG = true;
    public TableGen(String squery) {
    JDBCAdapter tabl = new JDBCAdapter("jdbc:odbc:ereg", "sun.jdbc.odbc.JdbcOdbcDriver",
    null,null);
    tabl.executeQuery(squery);
    table1 = new JTable(tabl);
    table1.setPreferredScrollableViewportSize(new Dimension(500, 70));
    //Create the scroll pane and add the table to it.
    scrollPane = new JScrollPane(table1);
    //Add the scroll pane to this window.
    class JDBCAdapter extends AbstractTableModel {
    Connection connection;
    Statement statement;
    ResultSet resultSet;
    String[] columnNames = {};
    Vector          rows = new Vector();
    ResultSetMetaData metaData;
    public JDBCAdapter(String url, String driverName,
    String user, String passwd) {
    try {
    Class.forName(driverName);
    System.out.println("Opening db connection");
    connection = DriverManager.getConnection(url, user, passwd);
    statement = connection.createStatement();
    catch (ClassNotFoundException ex) {
    System.err.println("Cannot find the database driver classes.");
    System.err.println(ex);
    catch (SQLException ex) {
    System.err.println("Cannot connect to this database.");
    System.err.println(ex);
    public void executeQuery(String query) {
    if (connection == null || statement == null) {
    System.err.println("There is no database to execute the query.");
    return;
    try {
    resultSet = statement.executeQuery(query);
    metaData = resultSet.getMetaData();
    int numberOfColumns = metaData.getColumnCount();
    columnNames = new String[numberOfColumns];
    // Get the column names and cache them.
    // Then we can close the connection.
    for(int column = 0; column < numberOfColumns; column++) {
    columnNames[column] = metaData.getColumnLabel(column+1);
    // Get all rows.
    rows = new Vector();
    while (resultSet.next()) {
    Vector newRow = new Vector();
    for (int i = 1; i <= getColumnCount(); i++) {
         newRow.addElement(resultSet.getObject(i));
    rows.addElement(newRow);
    // close(); Need to copy the metaData, bug in jdbc:odbc driver.
    fireTableChanged(null); // Tell the listeners a new table has arrived.
    catch (SQLException ex) {
    System.err.println(ex);
    public void close() throws SQLException {
    System.out.println("Closing db connection");
    resultSet.close();
    statement.close();
    connection.close();
    protected void finalize() throws Throwable {
    close();
    super.finalize();
    // Implementation of the TableModel Interface
    // MetaData
    public String getColumnName(int column) {
    if (columnNames[column] != null) {
    return columnNames[column];
    } else {
    return "";
    public Class getColumnClass(int column) {
    int type;
    try {
    type = metaData.getColumnType(column+1);
    catch (SQLException e) {
    return super.getColumnClass(column);
    switch(type) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    return String.class;
    case Types.BIT:
    return Boolean.class;
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
    return Integer.class;
    case Types.BIGINT:
    return Long.class;
    case Types.FLOAT:
    case Types.DOUBLE:
    return Double.class;
    case Types.DATE:
    return java.sql.Date.class;
    default:
    return Object.class;
    public boolean isCellEditable(int row, int column) {
    return true;
    public int getColumnCount() {
    return columnNames.length;
    // Data methods
    public int getRowCount() {
    return rows.size();
    public Object getValueAt(int aRow, int aColumn) {
    Vector row = (Vector)rows.elementAt(aRow);
    return row.elementAt(aColumn);
    public String dbRepresentation(int column, Object value) {
    int type;
    if (value == null) {
    return "null";
    try {
    type = metaData.getColumnType(column+1);
    catch (SQLException e) {
    return value.toString();
    switch(type) {
    case Types.INTEGER:
    case Types.DOUBLE:
    case Types.FLOAT:
    return value.toString();
    case Types.BIT:
    return ((Boolean)value).booleanValue() ? "true" : "false";
    case Types.DATE:
    return value.toString(); // This will need some conversion.
    default:
    return "'"+value.toString()+"'";
    public void setValueAt(Object value, int row, int column) {
    try {
    String tableName = metaData.getTableName(column+1);
    // Some of the drivers seem buggy, tableName should not be null.
    if (tableName == null) {
    System.out.println("Table name returned null.");
    String columnName = getColumnName(column);
    String query =
    "UPDATE "+tableName+
    " SET "+columnName+" = "+dbRepresentation(column, value)+
    " WHERE ";
    // We don't have a model of the schema so we don't know the
    // primary keys or which columns to lock on. To demonstrate
    // that editing is possible, we'll just lock on everything.
    for(int col = 0; col<getColumnCount(); col++) {
    String colName = getColumnName(col);
    if (colName.equals("")) {
    continue;
    if (col != 0) {
    query = query + " AND ";
    query = query + colName +" = "+
    dbRepresentation(col, getValueAt(row, col));
    System.out.println(query);
    statement.executeUpdate(query);
    catch (SQLException e) {
    //e.printStackTrace();
    System.err.println("Update failed");
    Vector dataRow = (Vector)rows.elementAt(row);
    dataRow.setElementAt(value, column);
    JScrollPane returnTabl()
    { return scrollPane;

    the setValueAt() method generate the SQL according to
    the selection on the JTable. The second update doesnt
    even generate any SQL query as it should always print
    it out in DOS even if update fails.there is only two possibilites remaining.
    1) there is a problem with the loop. seems unlikely.
    2) the setValueAt is not being called for some other reason.
    why don't you put some more lines to help you see what is happening.... some suggestions.
    uncomment the e.printStackTrace(); line
    put a System.out line at the start of the setValueAt method and through the iterations of the loop.

  • ORA-17085 bug jdbc update on where statement

    hi,
    i'm going crazy. i have this bug since 2009 and i don't know how to do.
    i'm sure it's a bug from jdbc oracle (because it's working with mysql)
    i guess it's not possible to do update on a row where this row is in the where query.
    1) Resultset with a where condition
    2) resultset.next
    3)resultset update (the where field)
    4) resultset next
    5) resultst previous
    6) resultset update (the where field)
    ---> ORA-17085
    let's do this table:
    the table:
    CREATE TABLE test (
    c1 NUMBER(10,0) NOT NULL,
    c2 VARCHAR2(5) NULL,
    c3 NUMBER,
    c4 VARCHAR(5)
    ALTER TABLE test
    ADD CONSTRAINT test_pk PRIMARY KEY (
    c1
    the code with the bug:
    here's the code to do this bug
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class MyMain
    Connection con;
    ResultSet res;
    Statement stat;
    public MyMain()
    System.out.println("Loading JDBC driver.");
    String url = "jdbc:oracle:thin:DEMO/[email protected]:1521:ORCL";
    String sPilote = "oracle.jdbc.driver.OracleDriver";
    //String url = "jdbc:mysql://localhost/test?user=demo&password=demo";
    //String sPilote = "com.mysql.jdbc.Driver";
    try
    Class.forName(sPilote);
    con = DriverManager.getConnection(url);
    stat = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    stat.execute("DELETE FROM test");
    stat.execute("INSERT INTO test(C1,C2,C3,C4) values (1,'C1',11,'C41')");
    stat.execute("INSERT INTO test(C1,C2,C3,C4) values (2,'C1',12,'C42')");
    stat.execute("INSERT INTO test(C1,C2,C3,C4) values (3,'C3',13,'C43')");
    stat.execute("INSERT INTO test(C1,C2,C3,C4) values (4,'C1',14,'C44')");
    stat.execute("INSERT INTO test(C1,C2,C3,C4) values (5,'C5',15,'C45')");
    stat.execute("INSERT INTO test(C1,C2,C3,C4) values (6,'C1',16,'C46')");
    // con.commit();
    // ERROR HERE
    //res = stat.executeQuery("SELECT c1,c2,c3,c4 FROM test ORDER BY c1"); // WHERE c2='C1'
    res = stat.executeQuery("SELECT c1,c2,c3,c4 FROM test WHERE c2='C1' ORDER BY c1");
    while (res.next())
    System.out.println("BEGIN: " + res.getInt("c1") + " " + res.getString("c2") + " " + res.getInt("c3") + " " + res.getString("c4"));
    res.first();
    res.next();
    System.out.println("-> UPDATE c2=c5");
    res.updateString(2, "C5");
    res.updateRow();
    // con.commit();
    System.out.println(res.getInt("c1") + " " + res.getString("c2") + " " + res.getInt("c3") + " " + res.getString("c4"));
    res.next();
    // con.commit();
    res.previous();
    System.out.println("-> UPDATE c2=c10");
    res.updateString(2, "C10");
    res.updateRow();
    System.out.println(res.getInt("c1") + " " + res.getString("c2") + " " + res.getInt("c3") + " " + res.getString("c4"));
    res.beforeFirst();
    while (res.next())
    res.refreshRow();
    System.out.println("END: " + res.getInt("c1") + " " + res.getString("c2") + " " + res.getInt("c3") + " " + res.getString("c4"));
    System.out.println("Finish.");
    catch (ClassNotFoundException e)
    e.printStackTrace();
    catch (SQLException e)
    // TODO Auto-generated catch block
    System.out.println( e.getErrorCode());
    e.printStackTrace();
    finally
    if (con != null)
    try
    con.close();
    catch (SQLException e)
    // TODO Auto-generated catch block
    e.printStackTrace();
    public static void main(String argv[])
    new MyMain();
    output:
    Loading JDBC driver.
    BEGIN: 1 C1 11 C41
    BEGIN: 2 C1 12 C42
    BEGIN: 4 C1 14 C44
    BEGIN: 6 C1 16 C46
    -> UPDATE c2=c5
    2 C1 12 C42
    -> UPDATE c2=c10
    17085
    java.sql.SQLException:
    so what to do to ask oracle to correct this bug ?
    thanks and have a nice day

    thanks for answer and sorry for not using code tag
    i want to open support request but we don't have support for oracle :-(
    well i try with all jdbc driver since 2009 and oracle 10g,10xe,11xe
    java is 1.6 and 1.7
    i really think it's about oracle jdbc because it's working with mysql.
    if i do where 1=1 then it's working because the bug happen only if i update a field who is in the "where query"
    let's see this code who has the same bug (more easy):
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class Test2 {
         Connection con;
         ResultSet res;
         Statement stat;
         public Test2() {
              System.out.println("Loading JDBC driver.");
              String url = "jdbc:oracle:thin:demo/[email protected]:1521:XE";
              String sPilote = "oracle.jdbc.driver.OracleDriver";
              try {
                   Class.forName(sPilote);
                   con = DriverManager.getConnection(url);
                   stat = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                             ResultSet.CONCUR_UPDATABLE);
                   stat.execute("DELETE FROM test");
                   stat.execute("INSERT INTO test(C1,C2,C3,C4) values (1,'C1',11,'C41')");
                   stat.execute("INSERT INTO test(C1,C2,C3,C4) values (2,'C1',12,'C42')");
                   stat.execute("INSERT INTO test(C1,C2,C3,C4) values (3,'C3',13,'C43')");
                   stat.execute("INSERT INTO test(C1,C2,C3,C4) values (4,'C1',14,'C44')");
                   stat.execute("INSERT INTO test(C1,C2,C3,C4) values (5,'C5',15,'C45')");
                   stat.execute("INSERT INTO test(C1,C2,C3,C4) values (6,'C1',16,'C46')");
                   res = stat
                             .executeQuery("SELECT c1,c2,c3,c4 FROM test WHERE c2='C1' ORDER BY c1");
                   res.first();
                   res.next();
                   System.out.println("-> UPDATE c2=c5");
                   res.updateString(2, "C5");
                   res.updateRow();
                   // con.commit();
                   res.refreshRow(); // don't change something
                   System.out.println(res.getInt("c1") + " " + res.getString("c2")
                             + " " + res.getInt("c3") + " " + res.getString("c4") +" should be: 2 C5 12 C42");
              } catch (ClassNotFoundException e) {
                   e.printStackTrace();
              } catch (SQLException e) {
                   System.out.println(e.getErrorCode());
                   e.printStackTrace();
              } finally {
                   if (con != null)
                        try {
                             con.close();
                        } catch (SQLException e) {
                             e.printStackTrace();
         public static void main(String argv[]) {
              new Test2();
    }output:
    Loading JDBC driver.
    -> UPDATE c2=c5
    2 C1 12 C42 should be: 2 C5 12 C42
    thanks a lot for your help

  • JDBC Update Problem

    Hi!
    I've just been experimenting with modifications to an MS Access database via Java methods (as opposed to sending SQL statements). Though deletion works fine, I get ODBC driver error messages when I attempt to update or insert. Is this because the JDBC-ODBC bridge driver does not support these methods for an Access database? The relevan section of code is shown below.
    Thanks in anticipation.
    Jan
    //*** ONLY THE DELETION WORKS! ACCESS GENERATES ODBC     ***
    //*** DRIVER ERROR MESSAGE FOR UPDATE AND INSERTION!!!     ***
    /*      //First the update...
         results.absolute(2);//Move to row 2 of ResultSet.
         results.updateFloat("balance", 42.55f);
         results.updateRow();
         //Now the insertion...
         results.moveToInsertRow();
         results.updateInt("acctNum", 999999);
         results.updateString("surname", "Harrison");
         results.updateString("firstNames", "Christine Dawn");
         results.updateFloat("balance", 2500f);
         results.insertRow();
         //Finally, the deletion...
         results.absolute(3); //Move to row 3.
         results.deleteRow();

    Cross-posted and answered at http://forum.java.sun.com/thread.jsp?forum=4&thread=266331

  • JDBC update 3.5 gives Oracle errors

    Running CF Enterprise Server 7.02 on win 2003 server.
    Installed the updated Data Direct JDBC drivers (version 3.5) and
    started getting following errors when run against Oracle 8i
    databases:
    This from queries that call stored procedures:
    Error Executing Database Query.[Macromedia][Oracle JDBC
    Driver][Oracle]ORA-02041: client database did not begin a
    transaction ORA-06512: at ""PAMOT.LATEST_LAB_DATA"", line 25
    ORA-06512: at line 1 The specific sequence of files included...
    This intermittently from queries that use cfqueryparam :
    Error Executing Database Query.[Macromedia][Oracle JDBC
    Driver]Internal error: Net8 protocol error. The specific sequence
    of files included...
    Have reverted to 3.4 drivers.
    Any idea what's going wrong?

    I just encountered this same error with CF Enterprise 7.02 on
    Win 2003 server connecting to an Oracle 8i database. On a whim I
    wrapped a <cftransaction> around the <cfquery> and the
    error went away. I have no idea why but it worked.

  • JDBC , UPDATE STATEMENT

    I am writing a Update Statement as fllows
    String sql= "update users_login set user_temp_pass='"+null_value+"' and user_pass='" + inputPwd + "'where user_id='"+inputUserid"';";
    But is still showing error saying that
    the statement has to be terminated by a ';'
    Please help me writing the statement correctly.

    Thank you, I have one more question.
    I am writing the following code to erase the temporary password and put the user choosen password.Somehow this is returning TRUE but the same changes are not appearing in the database.Please help me solving that.
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // Connection con = DriverManager.getConnection("jdbc:oracle:thin:@wdcorcl01dev:1521:USAD", "osis", "iss");
    con = DriverManager.getConnection("jdbc:oracle:thin:@wdcon01dev:1521:USAD", "osis", "iss");
    if (con == null) {
    System.out.println("Connection not found");
    stmt = con.createStatement();
    con.setAutoCommit(false);
    String sql= "update isis_users_login set user_temp_pass='"+null_value+"',user_pass='" + inputPwd + "'where user_id='" inputUserid "'";
    stmt.executeUpdate(sql);
    con.commit();
    returnString= true;
    } catch(SQLException sqlex) {
    sqlex.printStackTrace();
    returnString=false;
    } catch(Exception ex) {
    ex.printStackTrace();
    } finally {
    stmt.close();
    con.close();
    stmt = null;
    rs = null;
    con = null;
    return returnString;

  • Jdbc-updating spatial data

    i looked to the next link:
    http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html
    I want to update spatial data.To the previous link i found how to update tables but not how to update tables which contain spatial data.For example:
    CREATE TABLE customers (
    customer_id NUMBER,
    last_name VARCHAR2(30),
    first_name VARCHAR2(30),
    street_address VARCHAR2(40),
    city VARCHAR2(30),
    state_province_code VARCHAR2(2),
    postal_code VARCHAR2(9),
    cust_geo_location SDO_GEOMETRY);
    INSERT INTO customers VALUES
    (1001,'Nichols', 'Alexandra',
    '17 Maple Drive', 'Nashua', 'NH','03062',
    SDO_GEOMETRY(2001, 8307,
    SDO_POINT_TYPE (-71.48923,42.72347,NULL), NULL, NULL));
    if i want to update the costumer position (-71.48923,42.72347) how can i do this;;;

    Try posting this to the JDBC forum:
    http://forum.java.sun.com/forum.jspa?forumID=48

  • 3 of 300000 JDBC UPDATE iterations take 20 seconds

    I have a performance problem during update operations via JDBC.
    There is a single instance of TimesTen on one host, no replication, checkpoint is on, logging is on.
    I have one thread where I perform UPDATE operation in infinite loop. After 1000 iterations application sleeps for 10 milliseconds to prevent full CPU usage.
    According to the statistics, the performance is quite good (3000 TPS), but in each 300000 iterations (they take in average 0.33 milliseconds each) there are 3-4 iterations, each of them takes about 20 seconds!!
    When I turn loggging off (set Logging=2), the problem dissapear. But I can not disable logging because I need replication and replication requires parameter Temporary=1 either (it means no checkpointing).
    How to avoid iterations that take 20 seconds?
    Thanks in advance.
    Now details:
    Hardware:
    Dell PowerEdge SC1425, 2 Intel Xeon 3.2 GHz, 8 GB RAM
    Datasource config:
    # For testing big database
    [test_dsn]
    DataStore=/project/amironenko/x10_data/test_dsn
    DurableCommits=0
    PermSize=4000
    LogFileSize=8
    UID=test_dsn
    Data scheme:
    ttSchema test_dsn
    create table TEST_DSN.CHARGING_PROFILE (
    "ID" INTEGER not null,
    "NAME" VARCHAR(64) inline not null,
    primary key ("ID"));
    create unique index TEST_DSN.IDX_CHP_NAME on TEST_DSN.CHARGING_PROFILE
    ("NAME");
    create table TEST_DSN.COS (
    "ID" INTEGER not null,
    "NAME" VARCHAR(64) inline not null,
    primary key ("ID"));
    create unique index TEST_DSN.IDX_COS_NAME on TEST_DSN.COS ("NAME");
    create table TEST_DSN.CURRENCY (
    "ID" INTEGER not null,
    "NAME" VARCHAR(64) inline not null,
    primary key ("ID"));
    create unique index TEST_DSN.IDX_CUR_NAME on TEST_DSN.CURRENCY ("NAME");
    create table TEST_DSN."LANGUAGE" (
    "ID" INTEGER not null,
    "NAME" VARCHAR(64) inline not null,
    primary key ("ID"));
    create unique index TEST_DSN.IDX_LANG_NAME on TEST_DSN."LANGUAGE" ("NAME");
    create table TEST_DSN.SUB (
    "ID" INTEGER not null,
    MSISDN VARCHAR(32) inline not null,
    "NAME" VARCHAR(64) inline,
    SHORT_NUM VARCHAR(32) inline,
    ADDRESS VARCHAR(512) not inline,
    TYPE INTEGER not null,
    IS_LOCKED INTEGER not null,
    CHARGING_PROFILE_ID INTEGER,
    COS_ID INTEGER,
    CURRENCY_ID INTEGER,
    LANGUAGE_ID INTEGER,
    primary key ("ID"),
    foreign key (CHARGING_PROFILE_ID)
    references TEST_DSN.CHARGING_PROFILE ("ID"),
    foreign key (CHARGING_PROFILE_ID)
    references TEST_DSN.CHARGING_PROFILE ("ID"),
    foreign key (CHARGING_PROFILE_ID)
    references TEST_DSN.CHARGING_PROFILE ("ID"),
    foreign key (CHARGING_PROFILE_ID)
    references TEST_DSN.CHARGING_PROFILE ("ID"));
    create unique index TEST_DSN.IDX_SUB_MSISDN on TEST_DSN.SUB (MSISDN);
    create index TEST_DSN.IDX_SUB_NAME on TEST_DSN.SUB ("NAME");
    Data content:
    ttSize -tbl sub test_dsn
    Rows = 2000000
    Table in-line row bytes = 439414668
    Out-of-line columns:
    Column ADDRESS total 1088000000 avg size 512
    Total out-of-line column bytes = 1088000000
    Indexes:
    T-tree index TEST_DSN.IDX_SUB_MSISDN adds 40638489 bytes
    T-tree index TEST_DSN.IDX_SUB_NAME adds 40638489 bytes
    Hash index TEST_DSN.SUB with 200 buckets adds 60043689 bytes
    T-tree index TEST_DSN.TTFOREIGN_0 adds 40638489 bytes
    T-tree index TEST_DSN.TTFOREIGN_1 adds 40638489 bytes
    T-tree index TEST_DSN.TTFOREIGN_2 adds 40638489 bytes
    T-tree index TEST_DSN.TTFOREIGN_3 adds 40638489 bytes
    Total index bytes = 303874623
    Total = 1831289291
    Java code:
    private class WriteThread extends ThreadBase {
    private Connection conn = null;
    private PreparedStatement ps = null;
    private int count = 0;
    public WriteThread(String name, int rangeOfKeys, int objectSize, long nOfIterations, long sleepTime,
    long sleepInterval, boolean printLatency) {
    super( name, rangeOfKeys, objectSize, nOfIterations, sleepTime, sleepInterval,
    printLatency );
    log.info( "Thread " + getName() + " performs JDBC write operations" );
    try {
    conn = DriverManager.getConnection( url, login, password);
    conn.setAutoCommit( false );
    String sqlUpdate = "update sub set is_locked = ?, cos_id = ?, currency_id = ?, language_id = ? where msisdn = ?";
    ps = conn.prepareStatement( sqlUpdate );
    } catch( SQLException e ) {
    log.error( "unable to init conn", e );
    protected void doOperation() throws Exception {
    String msisdn = String.valueOf( ( int )( Math.random() * rangeOfKeys ) );
    if( ps != null ) {
    int psNum = 1;
    int isLocked = count % 2;
    int randomFK = count % 3 + 1;
    ps.setInt( psNum++, isLocked );
    ps.setInt( psNum++, randomFK );
    ps.setInt( psNum++, randomFK );
    ps.setInt( psNum++, randomFK );
    ps.setString( psNum++, msisdn );
    int result = ps.executeUpdate();
    if( result <= 0 )
    log.warn( "unable to update msisdn=" + msisdn + ", error code=" + result );
    conn.commit();
    ++count;
    Application's statistics:
    2007-02-13 17:51:06,269 0 [       main ] INFO test - jcache-class:com.x.test.JDBCPerf
    2007-02-13 17:51:06,273 4 [       main ] INFO test - TEST VERSION:200611081535
    2007-02-13 17:51:06,273 4 [       main ] INFO test - n-r:0
    2007-02-13 17:51:06,274 5 [       main ] INFO test - n-w:1
    2007-02-13 17:51:06,274 5 [       main ] INFO test - n-rw:0
    2007-02-13 17:51:06,274 5 [       main ] INFO test - key-range:2000000
    2007-02-13 17:51:06,275 6 [       main ] INFO test - obj-size:256
    2007-02-13 17:51:06,275 6 [       main ] INFO test - n-iter:1000000000
    2007-02-13 17:51:06,275 6 [       main ] INFO test - cluster-size:2
    2007-02-13 17:51:06,276 7 [       main ] INFO test - node-id:1
    2007-02-13 17:51:06,276 7 [       main ] INFO test - sleep-time:10
    2007-02-13 17:51:06,276 7 [       main ] INFO test - sleep-interval:1000
    2007-02-13 17:51:06,277 8 [       main ] INFO test - stdin-monitor:false
    2007-02-13 17:51:06,277 8 [       main ] INFO test - stat-interval-time:10000
    2007-02-13 17:51:06,277 8 [       main ] INFO test - jammer-thread:false
    2007-02-13 17:51:06,278 9 [       main ] INFO test - show-data-every-n-ops:1000000
    2007-02-13 17:51:06,278 9 [       main ] INFO test - login:test_dsn
    2007-02-13 17:51:06,278 9 [       main ] INFO test - password:123
    2007-02-13 17:51:06,279 10 [       main ] INFO test - driver-name:com.timesten.jdbc.TimesTenDriver
    2007-02-13 17:51:06,279 10 [       main ] INFO test - url:jdbc:timesten:direct:test_dsn
    2007-02-13 17:51:06,285 16 [       main ] INFO test - [Node #1] starting threads...
    2007-02-13 17:51:06,302 33 [       main ] INFO test - Thread w-0 performs JDBC write operations
    2007-02-13 17:51:06,420 151 [        w-0 ] INFO test - starting thread:w-0
    2007-02-13 17:51:06,521 252 [       stat ] INFO test - starting thread:stat
    2007-02-13 17:51:16,525 10256 [       stat ] INFO test - w-0     90308 iter-s, avg perf:     8937 TPS, immed perf:     8937 TPS
    2007-02-13 17:51:26,528 20259 [       stat ] INFO test - w-0     90308 iter-s, avg perf:     4491 TPS, immed perf:     0 TPS
    2007-02-13 17:51:36,531 30262 [       stat ] INFO test - w-0     93348 iter-s, avg perf:     3100 TPS, immed perf:     303 TPS
    2007-02-13 17:51:46,534 40265 [       stat ] INFO test - w-0     173437 iter-s, avg perf:     4323 TPS, immed perf:     8006 TPS
    2007-02-13 17:51:56,539 50270 [       stat ] INFO test - w-0     173437 iter-s, avg perf:     3460 TPS, immed perf:     0 TPS
    2007-02-13 17:52:06,542 60273 [       stat ] INFO test - w-0     192446 iter-s, avg perf:     3200 TPS, immed perf:     1900 TPS
    2007-02-13 17:52:16,545 70276 [       stat ] INFO test - w-0     249444 iter-s, avg perf:     3557 TPS, immed perf:     5698 TPS
    2007-02-13 17:52:26,550 80281 [       stat ] INFO test - w-0     249444 iter-s, avg perf:     3112 TPS, immed perf:     0 TPS
    2007-02-13 17:52:36,552 90283 [       stat ] INFO test - w-0     302940 iter-s, avg perf:     3361 TPS, immed perf:     5348 TPS
    2007-02-13 17:52:46,555 100286 [       stat ] INFO test - w-0     334091 iter-s, avg perf:     3336 TPS, immed perf:     3114 TPS
    2007-02-13 17:52:46,560 100291 [       stat ] INFO test - w-0     Latency, millis: min:0     max:22806     avg:0.26270387409419227     stddev:67.89072447133003
    2007-02-13 17:52:46,562 100293 [       stat ] INFO test - from 0 to 2280:     100:     334088
    2007-02-13 17:52:46,563 100294 [       stat ] INFO test - from 2280 to 4560:     0:     0
    2007-02-13 17:52:46,563 100294 [       stat ] INFO test - from 4560 to 6840:     0:     0
    2007-02-13 17:52:46,564 100295 [       stat ] INFO test - from 6840 to 9120:     0:     0
    2007-02-13 17:52:46,565 100296 [       stat ] INFO test - from 9120 to 11400:     0:     0
    2007-02-13 17:52:46,566 100297 [       stat ] INFO test - from 11400 to 13680:     0:     0
    2007-02-13 17:52:46,567 100298 [       stat ] INFO test - from 13680 to 15960:     0:     0
    2007-02-13 17:52:46,568 100299 [       stat ] INFO test - from 15960 to 18240:     0:     0
    2007-02-13 17:52:46,569 100300 [       stat ] INFO test - from 18240 to 20520:     0:     0
    2007-02-13 17:52:46,600 100331 [       stat ] INFO test - from 20520 to 22800:     0:     2
    2007-02-13 17:52:46,600 100331 [       stat ] INFO test - from 22800 to 25080:     0:     1

    Hi,
    This is a possible solution but the downside to this is that checkpoints nwo will take much longer. Before resorting to the checkpoint throttle you should try the following:
    1. Set LogBuffSize=65536 and set LogFileSize=64. If necessary you can even go bigger to LogBuffSize=131072 and LogFileSize=128.
    2. Be sure to allocate your checkpoint files and log file to different physical disks. The location of the checkpoint files is definied by the value of the DataStore ODBC attribute. By default the log files go in the same directory but this is very bad for any real-world write-intensive configuration. You can use the LogDir ODBC attribute to place the log files in a different directory (on a different disk!).
    3. Set CkptLogVolume=0 and unset CkptRate.
    In order to change LogDir you must destroy and re-create the datastore.
    You might want to try this first before you start playing with the CkptRate parameter...
    Chris

  • Jdbc - updating multiple tables

    Hello
    I am working on an old app using jdbc. There is a requirement to update several tables at once
    At the moment it is done roughly as follows
    //set autocommit to false
    PreparedStatement ps1 = connection.prepareStatement( sql_1 );
    //set parameters on ps1
    PreparedStatement ps2 = connection.prepareStatement( sql_2 );
    //set parameters on ps2
    ...and so on
    //execute updates on each statement
    connection.commit();
    However shouldnt this be done with batch processing? Are there any advantages/disadvantages to the above procedure?
    many thanks
    Stephen

    Batching should be faster. Let me guesstimate some numbers:
    A simple insert with not too many columns might take 5 ms. Do that ten times and it'll be 50 ms. A hundred inserts 500 ms.
    If you batch the inserts, one insert will still take 5 ms. Ten inserts might take 10 ms. A hundred inserts 50 ms.
    So you need to figure: how many inserts are you really doing and how often. If you are talking about saving half a second twice a day, stop messing with that already working and debugged code. Or do you insert 10,000 rows every minute all around the clock - at which point you may care significantly more.
    If you find that you might care, time your setup. Time the inserts you do now, then time it with batching. Different databases and drivers will greatly affect your mileage. There may be databases whose wire protocol does not even support batching.

  • Null PoinTEr Exception JDBC update

    hi guys the following exception is getting me mad!!!anyone can help please
    it is in an update statement ,here is the code:
    public void actionPerformed( ActionEvent event )
                            // INSERT TO  msg DATABASE
                             // SEND THE MESSAGE
                           connect con = new connect("Data");
                           String m_title = "";
                           String m_content = "";
                           m_title = title.getText();
                           m_content = msg_area.getText();
                         try
                                PreparedStatement ps = con.conn.prepareStatement("insert into messages (Title, Content) values (\'"+ "?" +"\',\'"+ "?" +"\');");
                      //here is the exception
                                    ps.setString(1,m_title);
                                     System.out.println("ih2");
                          ps.setString(2,m_content);
                              ps.executeUpdate();
                            //ps.executeUpdate();
                            stat1.close();
                            ps.close();
                               con.conn.close();
                             }Thanks in advance!

    ps.setString(1,"m_title");I bet that's not what you want. Do you really want to
    put the LITERAL "m_title" into the field, or did you
    mean to put the value of the VARIABLE m_titlle into
    it?
    ps.setString(1, m_title);yes actually that was a problem!!one last question when im using a delete sql statement a strange exception occurs:
    AN Unexpected error has been detected by hotspot virtual machine!!!
    what might cause such error in execution?
    here is the code:
         PreparedStatement ps = con.conn.prepareStatement("DELETE * FROM messages WHERE Title = ?");
         ps.setString(1,title_to_delete);
         res = ps.executeQuery();
                         ps.close();
                     res.close();
         con.conn.close();Thanks All!!

  • Jdbc updates not happening

    hi,
    i am trying ot insert records and then update them ,in message monitoring and channel i see it as success in DLVD stage but in actual database i do not see updates ,just the inserts happening.
    has anyone face such a situation ?
    Thanks.

    Hi ,
    I did not understand what do you want me to check ?
    i checked in message monitoring in the query , it forms the update query. even if it is not able to update or there is anything wrong ,it should catch the error somewhere in the channel or message monitoring, but in message monitoring i see a success flag although i do not see any update in real database.
    Please suggest
    Thanks

Maybe you are looking for

  • Getting prompted to Save As when using Save option

    We would like to deploy Reader XI with Protected Mode enabled. We have noticed that when using the Save option the user receives a prompt to Save As instead. I understand this is a security feature to basically grant Reader/Acrobat permission to save

  • Solaris 8 on Compaq laptop

    Hello, could you share your experience with Solaris 8 on Compaq laptops. I am going to buy Armada M700 - is there any problems with Solaris on it ? What network card do you recommend to use ? Thanks, -- Kevin

  • How to create a photo album direct on ipad?

    Hello, I want to create a photo album on my ipad but I'm not in town, so I have not my computer with me. There is a possibility to do it direct on the IPAD? Thank you

  • Mini SAP install problem:ACLs

    Hello, When I install,I am getting the followin message. The message is:"File system of SAP drive 'C:' doen not support ACLs(Access Control Lists). How to solve the above problem? please help me. With Regards, Jaheer,Yanbu.

  • Use Group Policy to prevent other network connections

    I need to define a Group Policy which says that IF a user is in the companys Domain network that no other connections are avaiable. So if the user is not connected to the Domain network he should be able to connect to any network he wants. Are there