JDBC 2.0 help

try
     Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Test;User=usr;Password=secret");
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String insertData = "Select * from users where UserID='123456'";
     ResultSet rs = stmt.executeQuery(insertData);
     rs.updateString("Name","Ashish");
     //rs.updateString("UserID","yyyasb3");
     rs.updateString("Dept","ACCT");
     rs.updateString("Aprv_Lvl","03");
     rs.updateString("Pwd","secret");
     rs.updateRow();
catch(Exception ex)
     out.println("The Exception is"+ex);
The above code gives me a SQL Exception: Invalid operation for the current cursor position

From the FIRST FEW sentences of the ResultSet API...
public interface ResultSet
A table of data representing a database result set, which is usually generated by executing a statement that queries the database.
A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set.

Similar Messages

  • Protocol Confusion of freeTDS jdbc driver, please help!

    I use freeTDS jdbc driver to connect to MS SQL 2000. In my programme, firstly I need to select sth out, and base on this update the other field in the same table. TOC will like that
    Statement stmt1 = conn.createStatement();
    ResultSet rs1 = stmt1.executeQuery("select sth from table");
    stmt1.executeUpdate("update table set field1 = 'xxx'");
    exception throw: java.sql.SQLException: Protocol confusion. Got a 0x79 packet
    I checked from the source of TDS driver, this exception throws when the sql query output is not a resultset.
    These 2 querys are prefectly okay individually, I tried to reverse the order, doesn't work neither. Even I disconnect the DB Connection and reconnect it before running the 2nd query, it won't help.
    Please help!

    I haven't used freetds, but seems like defaul version is 5.0. Try it with 7.0 and see it works better. By the way, JDBC driver's readme says that it was only tested with MSSQL 6.5 and 7.0.
    ---- FAQ from freetds.org ----
    Do I need to configure anything?
    When you untar the package you will need to run:
    $ ./configure
    You also have the following options you can add to the configure statement:
    --with-tdsver=VERSION
    specify the TDS version to use
    (4.2, 4.6, 5.0, or 7.0) [default is 5.0].
    --enable-msdblib
    enable Microsoft APIs and behaviour for DBLib
    --enable-dbmfix
    rename dbopen() to tdsdbopen() as a work around for dbm name conflict
    --with-gnu-ld
    assume the C compiler uses GNU ld [default=no]
    --enable-shared
    build shared libraries [default=yes]
    --enable-static
    build static libraries [default=yes]
    IMPORTANT You must build with TDS version 4.2 to access a MSSQL server or Sybase prior to 10.0! TDS 7.0 may also be used to talk to MS SQL 7 and above.

  • JDBC Adapter. Help required

    Hi All,
    Can JDBC Adapter be used for calling API for
    stored procedures of database.
    If yes please send blogs/docs for it.
    Regards

    hI Rick,
    Chek action=EXECUTE point from this link.
    http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
    Hope this helps you.
    Carlos

  • Tomcat 5.5 + JDBC connection pooling -- help

    I recently upgraded from java 1.4/tomcat 5.0 to java 1.5/tomcat 5.5. I am having difficulty getting connection pooling to work, however.
    Here are the details:
    1. Using mysql 4.1.3 beta -- it has been working fine for my purposes for a while
    2. put mysql-connector-java-3.1.7-bin.jar in tomcat/common/lib.
    3. Here is server.xml:
    <Server port="8005" shutdown="SHUTDOWN">
        <GlobalNamingResources>
            <Resource auth="Container" name="jdbc/TestDB"
            type="javax.sql.DataSource"/>
            <ResourceParams name="jdbc/TestDB">
                <parameter>
                    <name>url</name>
                    <value>jdbc:mysql://localhost:3306/TestDB?autoReconnect=true</value>
                </parameter>
                <parameter>
                    <name>maxIdle</name>
                    <value>40</value>
                </parameter>
                <parameter>
                    <name>maxActive</name>
                    <value>150</value>
                </parameter>
                <parameter>
                    <name>driverClassName</name>
                    <value>com.mysql.jdbc.Driver</value>
                </parameter>
                <parameter>
                    <name>maxWait</name>
                    <value>3000</value>
                </parameter>
                <parameter>
                    <name>removeAbandoned</name>
                    <value>true</value>
                </parameter>
                <parameter>
                    <name>username</name>
                    <value>webapp</value>
                </parameter>
                <parameter>
                    <name>factory</name>
                    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
                </parameter>
                <parameter>
                    <name>logAbandoned</name>
                    <value>true</value>
                </parameter>
                <parameter>
                    <name>removeAbandonedTimeout</name>
                    <value>90</value>
                </parameter>
                <parameter>
                    <name>password</name>
                    <value>secret</value>
                </parameter>
            </ResourceParams>
        </GlobalNamingResources>
        <Service name="Catalina">
            <Connector port="8080" />
            <Engine name="Catalina" defaultHost="localhost">
                <Host appBase="webapps"
                      autoDeploy="true"
                      debug="5"
                      liveDeploy="true"
                      name="localhost"
                      unpackWARs="true"
                      xmlValidation="true"/>
            </Engine>
        </Service>
    </Server>4. My application is called "bertle". Here is tomcat/conf/Catalina/localhost/bertle.xml:
    <Context path="/bertle" reloadable="true"
             docBase="C:\eclipse\workspace\bertle\bertle"
             workDir="C:\eclipse\workspace\bertle\work">
        <ResourceLink global="jdbc/TestDB"
                      name="jdbc/TestDB"
                      type="javax.sql.DataSource" />
    </Context>5. Tomcat starts up find without showing any errors. However, when I try and run the application I get an error. The error occurs when the user tries to log in, which involves querying the mysql database. Here is some of what it spits up:
    SEVERE: Error in validating user.
    Feb 28, 2005 5:05:16 PM edu.harvard.dsg.chv.model.LoginBean validateUser
    SEVERE: SQL statement =
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
         at  org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
         at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
         at mypackage.model.LoginBean.validateUser(LoginBean.java:49)
         at mypackage.action.LoginAction.execute(LoginAction.java:58)6. Here is the line at LoginBean.java:49:
    49    con = dataSource.getConnection();Here are the lines at LoginAction.java:58
    46        // Obtain our environment naming context
    47        Context initCtx = new InitialContext();
    48        Context envCtx = (Context) initCtx.lookup("java:comp/env");
    49       
    50        // Look up our data source
    51        DataSource ds = (DataSource) envCtx.lookup("jdbc/TestDB");
    52       
    53        // create a new LoginBean passing the datasource
    54        LoginBean lb = new LoginBean(ds);
    55       
    56        // check to see if this user/password combination are valid
    57        // will return a non-null UserDTO if valid
    58        UserDTO user = lb.validateUser((String)((DynaValidatorForm)form).get("handle"),
    59                (String)((DynaValidatorForm)form).get("password"));Is there something I am also supposed to add to WEB-INF/web.xml ?
    I am offering many kudos to anyone who can tell me what I am overlooking.
    Thanks,
    Jon

    the stuff you added in server.xml is old and wiilnot
    work with 5.5.*
    might pass dtd but it will not work
    did you try changing it to new layoutI gave you one Duke dollar for helping me with this.
    I will give another one to anyone who can tell me
    e how to set up global connection pooling in tomcat.Hi,
    Please bear with me for replying to a thread that's a week old.
    I was trying to set up connection pooling in tomcat and this thread helped me clear up some issues for the same.
    Incidentally google returns this thread among the top 10 when i search for tomcat 5.5 connection pooling.
    There are some unexplained questions here (regarding global connection pooling) and since I was able to set that up too, this may, in the future, benefit anybody who faces similar issues.
    Setting Up Global Connection Pooling
    Add this piece of code to server.xml under the server element
    <Server port="8005" shutdown="SHUTDOWN">
      <!-- other elements -->
      <GlobalNamingResources>
         <!-- other global resources-->
          <Resource name="jdbc/learning" auth="Container"                      type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver"
                         url="jdbc:oracle:thin:@localhost:1521:learning"
                         username="Learning" password="Learning" maxActive="20" maxIdle="10"  maxWait="-1"/>         
      </GlobalNamingResources>And then in your context file (which may be the <webapps>/<your appn>/META-INF/<your_web_app.xml> directory or conf/catalina/localhost/<your_web_app.xml>)
    add this code
    <Context docBase="${catalina.home}/webapps/webtest"
             privileged="true" antiResourceLocking="false" antiJARLocking="false">
    <!-- Use this if you dont require global resources
      <Resource name="jdbc/learning" auth="Container"
                         type="javax.sql.DataSource" driverClassName="oracle.jdbc.driver.OracleDriver"
                         url="jdbc:oracle:thin:@localhost:1521:learning"
                         username="Learning" password="Learning" maxActive="20" maxIdle="10"
                  maxWait="-1"/>
    -->
    <!-- this is a resource link if you have defined resource globally-->
    <ResourceLink
                name="jdbc/learning"
                global="jdbc/learning"
                type="javax.sql.DataSource"
              />
    </Context>also tomcat recommends defining the docBase outside the webapps directory (ie any other location outside the tomcat installation dir) if you choose to define contexts in xml files.
    thanks,
    ram.

  • What is wrong with my tiny jdbc program? Help!!!

    Hi,
    Would anyone diagnose the problem of my simple jdbc program?
    The situation is :
    a) local machine oracle thin driver connection; "lsnrctl" is running.
    b) I can query the statement "select id from gameUser" from SQLPLUS logged in as "scott", with desirable result.
    c) There are two code lines commented out in the code, if I uncomment them and instead comment out their counterparts and run the program, the "rset" would contain the result I want. But if I run the program unchanged, the output is only "hi".
    d) If I change the query statement to a wrong column name or a wrong table name, there would be a sql exception. So I surmise that the connection with the database is successful. But how come there is no query result???
    The follow is my coding.
    import java.sql.*;
    class dbAccess {
    public static void main (String args []) throws SQLException
    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    try{
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:orcl", "scott", "tiger");
    // ("jdbc:oracle:thin:orcl", "system", "manager");
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery("select ID from scott.gameUser");
    // ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
    while (rset.next())
    System.out.println (rset.getString(1)); stmt.close();
    System.out.println("hi");
    }catch (Exception e)
    System.out.println(e.toString());
    Thanks for help!

    "local machine oracle thin driver connection;" means that my jdbc application uses Oracle thin driver to connect to a Oracle database. The database and the application are both on the same local machine.
    "lsnrctl" is the command line program running to accept incomming request to connect to the database, it listens on the default 1521 port.
    I inserted two rows into the table and I could query these two rows in SQLPLUS.
    And I tried "select ID from gameUser", "select id from scott.gameUser" and various combination, it just won't retrieve the rows I inserted in the table.

  • JDBC virgin needs help.

    Hi, I am a 2nd year university student doing JDBC for the first time.
    I think my problem lies in the ODBC data sources rather than the code since the code works on the machine in university (NT) but not on my home PC (XP). When I run the code I get no errors but nothing happens in terms of interrogating or writing to the database (Access).
    I have tried a crude debug by performing a System.out.print at various stages and the result is that the message will display before I implement executeUpdate but not after. Any wise tips on how to ensure that my database is set up and working properly in XP? (I am sure this is the root of the problem rather than the code <supplied here anyway>)
    import java.sql.*;
    import java.io.DataInputStream;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class JDBCFrame extends JFrame implements ActionListener{
         JButton insert,extract,edit,delete;
         JTextField textid,textname;
         JTextArea output;
         JScrollPane scroll;
         Connection db_connection;
         Statement db_statement;
         public JDBCFrame(){
              // set up GUI
              Container content = this.getContentPane();
              content.setLayout(new GridLayout(5,1));
              textid=new JTextField("ID goes here");
              textname = new JTextField("Name goes here");
              content.add(textid);
              content.add(textname);
              insert = new JButton("Insert");
              insert.addActionListener(this);
              extract = new JButton("Extract");
              extract.addActionListener(this);
              edit = new JButton("Edit");
              edit.addActionListener(this);
              delete = new JButton("Delete");
              delete.addActionListener(this);
              content.add(insert);
              content.add(extract);
              content.add(edit);
              content.add(delete);
              output = new JTextArea();
              scroll = new JScrollPane(output);
              content.add(scroll);
              try{
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                   //String url = "jdbc:odbc:"+"demo";
                   String url = "jdbc:odbc:demo";
                   //String url = "jdbc:odbc:;Driver={Microsoft Access Driver (*.mdb)};DBQ=demo.mdb";
                   db_connection = DriverManager.getConnection(url,"","");
              catch(Exception ce){}
         public void actionPerformed(ActionEvent ev){
              if(ev.getSource()==extract){
                   try{
                        extract();
                   catch(Exception e){}
              if(ev.getSource()==edit){
                   try{
                        edit();
                   catch(Exception e){}
              if(ev.getSource()==insert){
                   try{
                        insert();
                   catch(Exception e){}
              if(ev.getSource()==delete){
                   try{
                        delete();
                   catch(Exception e){}
         public void edit() throws Exception{
              String names = textname.getText();
              String id = textid.getText();
              System.out.print("*** Connecting ***");
              db_statement.executeUpdate("UPDATE employee SET name="+names+"WHERE ID="+id);
              db_connection.commit();
         public void insert() throws Exception{
              String names = textname.getText();
              String id = textid.getText();
              db_statement.executeUpdate("INSERT INTO employee VALUES("+id+","+names+")");
              db_connection.commit();
         public void delete() throws Exception{
              String id = textid.getText();
              db_statement.executeUpdate("DELETE FROM employee WHERE ID= "+textid.getText());
         public void extract() throws Exception{
              output.setText("");
              if(textname.getText().equals("")){
                   ResultSet result2 = db_statement.executeQuery("SELECT * FROM employee WHERE ID="+textid.getText());
                   while(result2.next()){
                        output.setText(output.getText()+"ID:"+result2.getInt("ID")+"t"+result2.getString("Name")+"\n");
              ResultSet result=db_statement.executeQuery("SELECT * FROM employee WHERE name="+textname.getText()+"");
              while(result.next()){
                   output.setText(output.getText()+"ID:"+result.getInt("ID")+"\t"+result.getString("Name")+"\n");
         public static void main(String args[]){
              JDBCFrame win=new JDBCFrame();
              win.setSize(100,200);
              win.setVisible(true);
              win.addWindowListener(new WindowAdapter(){
                   public void windowClosing(WindowEvent e){
                        System.exit(0);
              

    Obviously "NullPointerException", because "db_statement" IS NEVER ASSIGNED A VALUE! [D'OH]
    Aren't you missing some code, like:
    db_statement = db_connection.createStatement();(for example)?
    Hope this helps.
    Good Luck,
    Avi.

  • JDBC connectivity please help...

    i already created a datasource at my administrative tools with
    Data Source Name: PayrollData
    Databse selected is:G:\java app\payroll\data\payrolldata.mdb
    payrolldata.mdb has a mastempl table this is a list of personnel.
    here is my code to connect to my database:
    protected void lostFoc(){
    String data="jdbc:odbc:PayrollData";
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn=DriverManager.getConnection(data,"","");
    Statement stm=conn.createStatement();
    ResultSet rsmastempl=stm.executeQuery("SELECT * FROM mastempl");
    txtecode.setText(rsmastempl.getString("ecode")); //display 1 of the many account numbers in the mastempl table.
    stm.close();
    catch (SQLException s){
    catch (Exception e){
    when executing this method from it seems that there is no records being retrieved and it seems that the ResultSet rsmastempl is empty.
    what is wrong with my code?
    thank u for helping me.
    killuasoft

    Hi
    After retriving data from batabase into resultset object,we have to keep a while condition which is modified as below,then it wont give empty
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn=DriverManager.getConnection(data,"","");
    Statement stm=conn.createStatement();
    ResultSet rsmastempl=stm.executeQuery("SELECT * FROM mastempl");
    while(rsmastempl.next)
    txtecode.setText(rsmastempl.getString("ecode")); //display 1 of the
    many account numbers in the mastempl table.
    stm.close();
    catch (SQLException s){
    catch (Exception e){
    }

  • Problem while connecting to DB2 through JDBC...Help PLZZZZZZZZZZZ

    Hi Everyone, I am facing this exception when I try to connect to DB2 to which installed on Z/OS. Please help me
    for your ref I am pasting my code below exception
    com.ibm.db2.jcc.b.SqlException: IO Exception opening socket to server 10.108.45.151 on port 446. The DB2 Server may be down.
         at com.ibm.db2.jcc.a.a.<init>(a.java:137)
         at com.ibm.db2.jcc.a.b.a(b.java:1542)
         at com.ibm.db2.jcc.b.o.<init>(o.java:795)
         at com.ibm.db2.jcc.a.b.<init>(b.java:298)
         at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:162)
    my code is:--
              try {
                   Class.forName("com.ibm.db2.jcc.DB2Driver");
              } catch (ClassNotFoundException se) {
                   se.printStackTrace();
                   System.out.println(se);
              try {
                        cn =DriverManager.getConnection("jdbc:db2://11.112.41.12:446/dbname","uname","pwd");
              } catch (Exception e) {
                   e.printStackTrace();
              }

    You will need to check this error message on metalink and likely on an SR.
    But with RAC you should not be connecting to the database, or in most cases, to a specific instance: You should be connecting to a TAF (or FCF) service.

  • JBO-26061, Error while opening JDBC connection, please help

    Hello
    I am new to JDeveloper suite.
    I tried to follow BC4J/JSP tutorial found in "JDeveloper Handbook" but every time I try to execute my starter page, I get the following error:
    Error Message: JBO-29000: Unexpected exception caught: oracle.jbo.DMLException, msg=JBO-26061: Error while opening JDBC connection.
    Connection test runs successfully in JDev itself and I had no trouble with creating BC4j components (entity object, view and application module), mapping fields etc. Bc4j.xcfg file looks OK as well as server.xml of OC4J server.
    I guess that OC4J server is unable to connect to database, but I cannot see why and what could be done about it.
    Any recommendations would be warmly appreciated. Please send cc to [email protected] as well.
    Thanks in advance,
    Kristjan

    Kristjan,
    BC4J has a tester that can be used to test applications. Right mousew click onto the Application Module and choose tester from the menu. Use setting as defaulted. If this can't connect, then obviously the database connection defined for the Application module is different from the one you are testing. Also, make sure the database password of the connection gets deployed (checkbox option in the connection dialog)
    Frank

  • Relational queries through JDBC with the help of Kodo's metadata for O/R mapping

    Due to JDOQL's limitations (inability to express joins, when relationships
    are not modeled as object references), I find myself needing to drop down to
    expressing some queries in SQL through JDBC. However, I still want my Java
    code to remain independent of the O/R mapping. I would like to be able to
    formulate the SQL without hardcoding any knowledge of the relational table
    and column names, by using Kodo's metadata. After poking around the Kodo
    Javadocs, it appears as though the relevant calls are as follows:
    ClassMetaData cmd = ClassMetaData.getInstance(MyPCObject.class, pm);
    FieldMetaData fmd = cmd.getDeclaredField( "myField" );
    PersistenceManagerFactory pmf = pm.getPersistenceManagerFactory();
    JDBCConfiguration conf = (JDBCConfiguration)
    ((EEPersistenceManagerFactory)pmf).getConfiguration();
    ClassResolver resolver = pm.getClassResolver(MyPCObject.class);
    Connector connector = new PersistenceManagerConnector(
    (PersistenceManagerImpl) pm );
    DBDictionary dict = conf.getDictionary( connector );
    FieldMapping fm = ClassMapping.getFieldMapping(fmd, conf, resolver, dict);
    Column[] cols = fm.getDataColumns();
    Does that look about right?
    Here's what I'm trying to do:
    class Foo
    String name; // application identity
    String bar; // foreign key to Bar
    class Bar
    String name; // application identity
    int weight;
    Let's say I want to query for all Foo instances for which its bar.weight >
    100. Clearly this is trivial to do in JDOQL, if Foo.bar is an object
    reference to Bar. But there are frequently good reasons for modeling
    relationships as above, for example when Foo and Bar are DTOs exposed by the
    remote interface of an EJB. (Yeah, yeah, I'm lazy, using my
    PersistenceCapable classes as both the DAOs and the DTOs.) But I still want
    to do queries that navigate the relationship; it would be nice to do it in
    JDOQL directly. I will also want to do other weird-ass queries that would
    definitely only be expressible in SQL. Hence, I'll need Kodo's O/R mapping
    metadata.
    Is there anything terribly flawed with this logic?
    Ben

    I have a one point before I get to this:
    There is nothing wrong with using PC instances as both DAO and DTO
    objects. In fact, I strongly recommend this for most J2EE/JDO design.
    However, there should be no need to expose the foreign key values... use
    application identity to quickly reconstitute an object id (which can in
    turn find the persistent version), or like the j2ee tutorial, store the
    object id in some form (Object or String) and use that to re-find the
    matching persistent instance at the EJB tier.
    Otherwise, there is a much easier way of finding ClassMapping instances
    and in turn FieldMapping instances (see ClassMapping.getInstance () in
    the JavaDocs).
    Ben Eng wrote:
    Due to JDOQL's limitations (inability to express joins, when relationships
    are not modeled as object references), I find myself needing to drop down to
    expressing some queries in SQL through JDBC. However, I still want my Java
    code to remain independent of the O/R mapping. I would like to be able to
    formulate the SQL without hardcoding any knowledge of the relational table
    and column names, by using Kodo's metadata. After poking around the Kodo
    Javadocs, it appears as though the relevant calls are as follows:
    ClassMetaData cmd = ClassMetaData.getInstance(MyPCObject.class, pm);
    FieldMetaData fmd = cmd.getDeclaredField( "myField" );
    PersistenceManagerFactory pmf = pm.getPersistenceManagerFactory();
    JDBCConfiguration conf = (JDBCConfiguration)
    ((EEPersistenceManagerFactory)pmf).getConfiguration();
    ClassResolver resolver = pm.getClassResolver(MyPCObject.class);
    Connector connector = new PersistenceManagerConnector(
    (PersistenceManagerImpl) pm );
    DBDictionary dict = conf.getDictionary( connector );
    FieldMapping fm = ClassMapping.getFieldMapping(fmd, conf, resolver, dict);
    Column[] cols = fm.getDataColumns();
    Does that look about right?
    Here's what I'm trying to do:
    class Foo
    String name; // application identity
    String bar; // foreign key to Bar
    class Bar
    String name; // application identity
    int weight;
    Let's say I want to query for all Foo instances for which its bar.weight >
    100. Clearly this is trivial to do in JDOQL, if Foo.bar is an object
    reference to Bar. But there are frequently good reasons for modeling
    relationships as above, for example when Foo and Bar are DTOs exposed by the
    remote interface of an EJB. (Yeah, yeah, I'm lazy, using my
    PersistenceCapable classes as both the DAOs and the DTOs.) But I still want
    to do queries that navigate the relationship; it would be nice to do it in
    JDOQL directly. I will also want to do other weird-ass queries that would
    definitely only be expressible in SQL. Hence, I'll need Kodo's O/R mapping
    metadata.
    Is there anything terribly flawed with this logic?
    Ben
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • JDBC Stored procedure help required

    Hi All,
    Please let me know simple blogs how to use JDBC Stored procedure or any other method  in receiver jdbc adapter to insert or select in 2 tables
    Please  let me know simple blogs how to use JDBC Stored procedure or any other method  in sender jdbc adapter to select from 2 tables
    Thanks

    Hi,
    I am also looking for JDBC Stored procedure or any other method in sender jdbc adapter to select data from 2 tables
    Thanks

  • Problem with get ResultSet from rmi jdbc method. Help.

    Hi,
    I am writing a rmi jdbc server. I got all the rmi methods working, but I am trying to get the data from the ResultSet. After the query, I set the fields in the serialiable class and return it back to the client. However, I noticed that it does called init(), but not the setField calls. When it calls the first setField in the serialiable class, the method is never called. Can anyone give some guidance.
    Thanks,
    Rage
    This method is called from the client to set all the data in the Serialiable class and return it to the client.
    public Collection fetchResultSet() throws RemoteException
    System.out.println("Entering fetchResultSet");
    Collection resultSetColl = new ArrayList();
    QueryResultSet recordset;
    try
    int rowCount = 0;
    ResultSetMetaData rsmd = rs.getMetaData(); // Get data dictionary information
    int columnCount = rsmd.getColumnCount();
    System.out.println("got column count");
    System.out.println("" + rowCount + " rows, " +
    columnCount + " columns");
    if (rs == null) System.out.println("rs is null");
    if (rs.next())
    System.out.println("Parsing RS");
    recordset = new QueryResultSet();
    for (int i = 1; i <= columnCount; i++)
    System.out.println("set Fields = "+ rs.getString(i) );
    //recordset.setField(i,rs.getString(i));
    String strValue = rs.getString(i);
    recordset.setField(i,strValue);
    System.out.println("Added recordset" );
    resultSetColl.add(recordset);
    catch (Exception e)
    System.out.println(e.getMessage());
    closeResultSet();
    return resultSetColl;
    Here is my Serializable Class
    import java.io.*;
    import java.sql.*;
    public class QueryResultSet implements Serializable
    private String Field1;
    private String Field2;
    private String Field3;
    private String Field4;
    private String Field5;
    private String Field6;
    private String Field7;
    private String Field8;
    private String Field9;
    private String Field10;
    private String Field11;
    private String Field12;
    private String Field13;
    /** Creates a new instance of QueryResultSet */
    public QueryResultSet()
    init();
    public void init()
    System.out.println("QueryResultSet INIT()");
    Field1 = "";
    Field2 = "";
    Field3 = "";
    Field4 = "";
    Field5 = "";
    Field6 = "";
    Field7 = "";
    Field8 = "";
    Field9 = "";
    Field10 = "";
    Field11 = "";
    Field12 = "";
    Field13 = "";
    public String getField(int nField)
    System.out.println("QueryResultSet getField()");
    System.out.println("getField 1 = " + Field1);
    if (nField ==1)
    return Field1;
    else if (nField == 2)
    return Field2;
    else if (nField == 3)
    return Field3;
    else if (nField == 4)
    return Field4;
    else if (nField == 5)
    return Field5;
    else if (nField == 6)
    return Field6;
    else if (nField == 7)
    return Field7;
    else if (nField == 8)
    return Field8;
    else if (nField == 9)
    return Field9;
    else if (nField == 10)
    return Field10;
    else if (nField == 11)
    return Field11;
    else if (nField == 12)
    return Field12;
    else if (nField == 13)
    return Field13;
    return null;
    public void setField(int nField, String strField)
    System.out.println("QueryResultSet setField()");
    System.out.println("field #" String.valueOf(nField) " = " + strField);
    if (nField == 1)
    Field1 = strField;
    else if (nField == 2)
    Field2 = strField;
    else if (nField == 3)
    Field3 = strField;
    else if (nField == 4)
    Field4 = strField;
    else if (nField == 5)
    Field5 = strField;
    else if (nField == 6)
    Field6 = strField;
    else if (nField == 7)
    Field7 = strField;
    else if (nField == 8)
    Field8 = strField;
    else if (nField == 9)
    Field9 = strField;
    else if (nField == 10)
    Field10 = strField;
    else if (nField == 11)
    Field11 = strField;
    else if (nField == 12)
    Field12 = strField;
    else if (nField == 13)
    Field13 = strField;
    }

    You need to give us some information more. Like what rdbms are you using, what driver and how are you trying to access the resultset from java.
    I do not know what are you using. One thing I can tell you for sure is that the execute method returns a boolean. If you need a resultset you should run executeQuery.
    Kiros

  • Variables expression in the JDBC. problems need help!

    Dear Sir,
    I am a beginner of using JDBC. I have a problem in the variable expression.
    the fragment code is below
    int today = 20041009;
    ResultSet rs = statement.executeQuery("select * from recorder where bookeddate >= 'today' order by bookeddate");
    I want to order the "booked date" and select the date after today. Unfortunately, it doesn't work. Any person can tell me how to add variable 'today' in to the SQL? I used mySQL
    If this question is tooo stupid, please forgive me.
    Thanks
    Daan

    Dear Sir,
    I am a beginner of using JDBC. I have a problem in the
    variable expression.
    the fragment code is below
    int today = 20041009;
    ResultSet rs = statement.executeQuery("select * from
    recorder where bookeddate >= 'today' order by
    bookeddate");
    I want to order the "booked date" and select the date
    after today. Unfortunately, it doesn't work. Any
    person can tell me how to add variable 'today' in to
    the SQL? I used mySQL
    If this question is tooo stupid, please forgive me.
    what type of field is bookeddate.. a DATE or TIMESTAMP?
    the format you have is a TIMESTAMP.
    once you have solved the problem of actually including the variable in your query (as the previous poster mentioned) if you still have difficulty make sure you are using the right format for the given field.
    you might well want to look at using prepared statements as well because they will handle the formatting for you.. you will need to convert your int variable today into an actual Date object though.

  • Problems connecting using MM.MySQL JDBC driver - Please Help

    I have been trying to get the driver to work for the past two days and have hit a brick wall. If someone could offer any ideas on what other steps to try I would so much appreciate it. Here's the situation:
    I'm working on Mac OS X.1, jdk 1.3, mysql (database) and using the mm.mysql driver version 2.0.6.1. I'm using a test script which loads the driver, tries to connect to the 'test' database (which doesn't require a username/password) and then prints out the systems date when successful.
    //load the driver
    Class.forName("org.gjt.mm.mysql.Driver");
    //Try connecting to db
    Connection conn = DriverManager.getConnection(jdbc:mysql:///test", "", "");
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery("SELECT now();");
    while (rset.next())
    System.out.println(rset.getString(1));
    // Close result set, statement and DB connection
    rset.close();
    stmt.close();
    conn.close();
    The problem is that everytime I run the script I get an error telling me that the driver could not be found:
    Exception in thread "main" java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
    ��������at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    ��������at java.security.AccessController.doPrivileged(Native Method)
    ������at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    ��������at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
    ��������at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.j
    The mysql database is running in the background, the driver's path location has been added to my classpath and I've also tried modifying the driver name as well as using older versions of the driver itself, but still no luck. This needs to be up and running so I can finalize a project I've been working on. If anyone has any ideas on what I could possibly try next, I welcome the suggestions.
    Thanks in advance.

    I didn't realize you had to extract the information either.
    Ok.. so I downloaded the latest jar file from sourceforge, extracted the data and IT WORKED!! Thank you so much. You saved my head from exploding.
    Many thanks.
    -c

  • Sun Jdbc and j++, Help!!!

    Hello,
    I'm trying to use the Sun Jdbc-Odbc bridge with MS J++.
    if I import the rt.jar file to the classpath of my project in j++, as I run or debug the project, I get the following error message: "Unable to locate system class: java/lang/String"
    How do I use the sun Jdbc-Odbc bridge, on the MS - J++
    environment?
    so far I managed to work with JBuilder, but I have a slow computer, and J++ is my only solution.
    thanks in advance....

    Hi,
    J++ has its own VM. You cannot add the runtime classes from another VM because this will cause incompatibilities between them.
    There are other IDE's that are faster then JBuilder (like RealJ or JCreator). Perhaps you can use one of those.
    I think there is also a jdbc-odbc bridge delivered with J++, but I can't remember its exact class name. I don't recommend using it since MS doesn't support J++ anymore.

Maybe you are looking for