Jdbc:BatchUpdate!help:)

I 'm writing a program where I have to read many lines of record from a table and write it to another.
I use PreparedStatement.addBatch()/executeBatch().
But the efficiency is so low that writing 7562 lines of records have taken 45 minutes.How to improve it?Lend me a hand.Thank you in advance.

When dealing with large sets of database records, I'm tend to look at any database performance tuning options. The solution depends a fair bit on what you are trying to do.
If the SQL statement reads in x number of records based on given parametera nd extracts the raw data, I suggest using a database view on top of the base table.This eliminates the huge traffic incurred reading/writing to the database.
Database triggers are another option to consider. Triggers also have the advantage of spreading the database load over a more even period, rather than slugging the db in one go.
Also ask yourself if you really do need to read the currect data being extracted ? Are there any large columns that can be ignored, or removed ? Can you make do with just the primary keys which you can later access ?
Lazy load the result sets if possible. No point running the query if there is a very good chance it isn't needed.

Similar Messages

  • JDBC URL helper class

    Hi,
    Was trying use third party(Caucho) jdbc type 4 driver for MySQL. I updated the
    jdbcdrivers.xml to include the details for the new driver. However, when using
    Config wizard, how (or where) do i provide a JDBC url helper class, so that the
    config wizard can connect the database using the jdbc url?
    Amit.

    Amit wrote:
    Joe Weinstein <[email protected]> wrote:
    Actually, all you need to do is get the driver you want into the weblogic
    classpath, and then tell the pool the class name you want for the driver,
    and give it the URL and properties it needs.
    Joe
    Hi. In order to implement a custom default, you would need to have
    a URLHelper class, as the other entries refer. I don't know that we
    offer a way to create Defaults, but you should be able to create a pool
    from the console by specifically typing in the class name and the URL.
    Is that not true?
    Joe
    >
    >
    Thanks Joe,
    But i wanted to see the jdbc url changed in the config wizard screen (as pointed
    in the pic). Caucho jdbc driver has url like "jdbc:mysql-caucho://hostname:port/database".
    Others mysql drivers have url like "jdbc:mysql://hostname:port/database. So where
    exactly could i tweek that property, since all that is editable is hostname, port,
    and database?

  • Proxies to jdbc scenario help...!

    Dear All,
    I am very new to XI , can anyone guide me step by step process for
    1. File to webservice scenario via xi
    2. Proxies to jdbc  scenario via xi
    3.IDOC to JDBC scenario via xi
    will be much helpful as i need to complete these processes very soon.
    Thanks in Advance.

    HI,
    Here are the documents:
    Webservice scenario:
    these 3 documents should explain it all,
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/befdeb90-0201-0010-059b-f222711d10c0
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5f3ee9d7-0901-0010-1096-f5b548ac1555
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d23cbe11-0d01-0010-5287-873a22024f79
    troubleshooting SOAP:
    /people/varadharajan.krishnasamy/blog/2007/01/09/troubleshooting-soap-message--xi
    IDOC and JDBC Scenarios:
    /people/prateek.shah/blog/2005/06/08/introduction-to-idoc-xi-file-scenario-and-complete-walk-through-for-starters --> For Idoc sender: IDOC -file
    /people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30 --> for jdbc receiver: file -JDBC
    IDOC configuration :
    Refer the help:
    /people/swaroopa.vishwanath/blog/2007/01/22/ale-configuration-for-pushing-idocs-from-sap-to-xi - ALE settings for R3-XI
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e07dcaa0-a92b-2a10-3a96-b3d942bd1539
    Idoc to File:
    /people/prateek.shah/blog/2005/06/08/introduction-to-idoc-xi-file-scenario-and-complete-walk-through-for-starters
    This is expalined both the scenarios:
    Please follow the below process for configuration:
    Pre-requisites for Inbound IDoc to R/3 from PI:
    Configuration required at Xi side:
    Go to IDX1: configure the port.
    Go to IDX2: load the DOC metadata.
    Go to SM59: Create RFC destination which points to R3 system this is require in the case where your IDOC is sent to R 3 system,
    Configiration required at R3 side:
    Maintain Logical System for PI (SALE transaction):
    Maintain Partner Profile for XI system(WE20):
    Pre-requisites for Outbound IDoc from R/3 to PI:
    Configurations required in R/3:
    Maintain Logical System (SALE)
    Define RFC Destination (SM59) which points to PI system
    Maintain Port (WE21)
    Maintain partner profile. (WE20):
    Maintain Distribution Model (BD64):
    JDBC:
    Receiver JDBC scenario MS access - /people/sameer.shadab/blog/2005/10/24/connecting-to-ms-access-using-receiver-jdbc-adapter-without-dsn
    Writing Stored Procedures-
    /people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
    http://www.ics.com/support/docs/dx/1.5/tut6.html
    /people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi
    http://www.ics.com/support/docs/dx/1.5/tut6.html
    http://java.sun.com/docs/books/tutorial/jdbc/basics/sql.html
    http://www.sqlteam.com/article/stored-procedures-an-overview
    Proxy:
    Client Proxy:
    /people/ravikumar.allampallam/blog/2005/03/14/abap-proxies-in-xiclient-proxy
    Server Proxy:
    /people/siva.maranani/blog/2005/04/03/abap-server-proxies
    Smarter Approach for coding ABAP Proxies
    /people/sravya.talanki2/blog/2006/07/28/smarter-approach-for-coding-abap-proxies
    File to Inbound Proxy:
    /people/prateek.shah/blog/2005/06/14/file-to-r3-via-abap-proxy
    How do you activate ABAP Proxies?
    /people/vijaya.kumari2/blog/2006/01/26/how-do-you-activate-abap-proxies
    Debugging Inbound Proxy:
    /people/stefan.grube/blog/2006/07/28/xi-debug-your-inbound-abap-proxy-implementation
    Thanks and Regards,
    Chirag Gohil

  • Error with SQLServer-JDBC(PLease Help)

    Hello,
    I use before Oracle with Java, but it's first time when I use MS SQL Server, and I made this litle programm Just I want to connect to the Data base, and I get error when I run the programm
    Here you have the file :
    import com.microsoft.jdbc.sqlserver.*;
    import java.sql.*;
    import java.io.*;
    class JDBC_Connect
    public static void main(String args[])
    Connection connexion = null;
    Statement requete = null;
    ResultSet resultSet;
    int i = 1;
    String req1 = "SELECT Name FROM Test";
    try
    String strClassName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String strUrl = "jdbc:microsoft:sqlserver://localhost:1433;"
    + "user=sa; DatabaseName=VJ";
    Class.forName(strClassName);
    connexion = DriverManager.getConnection(strUrl);
    requete = connexion.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_READ_ONLY);
    resultSet= requete.executeQuery(req1);
    while(resultSet.next())
    System.out.println( resultSet.getString(1));
    i++;
    catch(ClassNotFoundException e) {
    System.err.println("ERREUR : Driver manquant.");
    e.printStackTrace();
    catch(SQLException se) {
    System.out.println("ERREUR SQL : !" + se);
    and here you have the Error that I get
    ERREUR SQL : ! Java.sql.SQLEXception: [Microsoft][SQLServer 2000 Driver for JDBC]
    [SQLServer]Invalid object name 'Test'
    and Test is the name of the Table
    Please If you have an idea about, response my THread, I really need your Help.
    Thanks in advance for your answer.
    Best regards.

    Hi,
    1. When i write the connetion string "con1=DriverManager.getConnection("jdbc:microsoft:sqlserver://ServerName:1433;*Database*=dmo1o2d",user,password);
    Then give message that Connetion is successful. But i put DatabaseName instead of Databse then give error *"java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Cannot open database requested in login 'testcq'*. Login fails.
    2. if i run query like this select * from testcq.sa.test then gives *error "Msg 208, Level 16, State 1, Line 1*
    Invalid object name 'testcq.sa.test'." from MS SQL server management studio
    tescq is Databse name, sa is loging name in MS SQL server mangement stidio to connet to server. test is table name.
    3. if i run query like this select * from testcq.dbo.test then gives all row from MS SQL mangement Studio. But when i rtyr to
    run from java code gives erro "j*ava.sql.SQLException: [Microsoft][SQLServer 2000 Driver for*   
    *   JDBC][SQLServer]Invalid object name 'testcq.dbo.test*'.
    I don't understand where the problem is. It's either in database or in table...all the code, table,database are fine..
    Kindly do needful .....bcoz so many days i m working with this....

  • Help needed with JDBC - please help! (newbie)

    hi all
    i m new to jdbc
    i have installed MySQL server on my winxp machine
    i used the command:
    mysql -p -u root
    Enter password: ****now when writing a prog i m getting a prob at this piece of code:
    Connection con=DriverManager.getConnection("jdbc:odbc:books","root","root");wot is wrong wid this code?
    please help......
    thanks in advance

    There are about 20 different things that could be wrong a this point; I'm not going to list them all. If you want specific help, you need to post specific information. This is usually done by posting either a stack trace from an exception, or a more complete section of code and a description of the problem and ALL the symptoms. You have all the information on what you've done, we have none of it.
    Instead of trying to diagnose whats wrong with your ODBC setup, I'm going to give you some strong advice; don't use ODBC with JDBC if you can avoid it, and with MySQL you can avoid it. It makes things simpler, less can go wrong, and you don't have to configure a DSN on every machine that you install the program on.
    To use "pure" JDBC without ODBC for MySQl:
    1) download the JDBC driver (you might already have this)
    http://dev.mysql.com/downloads/connector/j/3.1.html
    2) follow the installation instructions
    http://dev.mysql.com/doc/refman/5.0/en/java-connector.html
    In particular, make sure your classpath is set correctly
    3) Here's an example of loading the driver and establishing a connection
    http://dev.mysql.com/doc/refman/5.0/en/cj-connect-with-drivermanager.html
    Note the form of the connection URL,
    "jdbc:mysql://localhost/test?user=monty&password=greatsqldb"
    This is what an URL without ODBC looks like; there is no DSN, which means no DSN has to be configured.
    4) The MySQL database has some built-in security, to prevent malicious connections from outside computers. Solutions to that and other common problems are here:
    http://dev.mysql.com/doc/refman/5.0/en/cj-faq.html

  • Jdbc-servlet help!!!!!!!!

    excuse my english.
    hey folks, i got this problem:
    i`m trying to do a simple servlet that`s throw a html with a result, but i always got this error:
    java.lang.NullPointerException
    at ConsultaServlet.doPost(ConsultaServlet.java:45)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    THIS IS THE CODE I HAVE:
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HolaServlet extends HttpServlet {
    private Connection con;
    private PrintWriter out;
    private Statement stmt;
    public void init(ServletConfig conf)
    throws ServletException {
    super.init(conf);
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con =DriverManager.getConnection("jdbc:odbc:MS Access Database");
    }catch(Exception e) {
    System.err.println(e);
    public void service(HttpServletRequest req,
    HttpServletResponse res)
    throws ServletException, IOException {
    res.setContentType("text/html");
    try {   
    out = res.getWriter();
    out.println("<html>");
    out.println("<head>");
    out.println("<title> Sample JDBC Servlet Demo" +
    "</title>");
    out.println("</head>");
    out.println("<body>");
    stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("select * from empleados");
    out.println("<UL>");
    while(rs.next()) {
    out.println("<LI>" + rs.getString("nombre"));
    out.println("</UL>");
    rs.close();
    stmt.close();
    } catch(SQLException e) {
    out.println("An SQL Exception was thrown.");
    } catch(IOException e) {
    System.err.println("An IOException was thrown.");
    out.println("</body>");
    out.println("</html>");
    out.close();
    public void destroy(){
    try{
    con.close();
    }catch(SQLException e) {
    Can someone tell me what i`m doing wrong.
    THANK.

    Hi,
    I have intalled the Javawebserver2.0
    Its been installed on C:\javawebserver2.0.
    After this I have set the autoexec.bat path as
    PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:\ORAWIN95\bin;c:\Oracle\Ora81\bin;"C:\ProgramFiles\Oracle\jre\1.1.7\bin";c:\j2sdk1.4.2_04\bin;c:\JavaWebServer2.0\bin;c:\Jsdk2.0\bin
    rem - By Windows 98 Network for Netware Upgrade - c:\windows\odihlp.exe
    set classpath=.;c:\j2dsk1.4.2_04\jre\lib;c:\j2dsdk1.4.2_04\lib;c:\j2sdk1.4.2_04\bin;c:\JavaWebServer2.0\lib;c:\Jsdk2.0\lib
    rem -;c:\jsdk2.1\src ;c:\jsdk2.1\lib;c:\Jsdk2.0\src
    After doing this I wrote my first servlet program in the servlets directory of javawebserver2.0 saved and when I went to compile its not compiling throwing an error showing that it is unable to locate all the servlet packages. So in I thought might be there are 2 things one is either I have not imported javax.servlet.* and javax.servlet.httpServlet.* package, but I had included it, the next thing was to check the autoexec.bat path. I included in that javawebserver2.0 path. Now first I am not able to compile the servlet program. Can you help me with it.
    I had downloaded jsdk2 from net and have given its path also in the autoexec but nothing is happening. I am using the following package to write and develop Java programs "j2sdk1.4.2_04". Can you explain to where I am going wrong. Please its a bit urgent.
    Following is the program:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class helloWorld extends HttpServlet
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
    res.setContentType("text/html");
    PrintWriter out=res.getWriter();
    out.println("<html>");
    out.println("<head><Title>Hello World</title></head>");
    out.println("<body><big>Hello World</big>");
    out.println("</body>");
    out.println("</html>");
    Help!!!!!!!!

  • JDBC Connection Help

    Can anyone help me by telling me the syntax of the
    Class.for.Name and the RegisterDriver classes for the case of
    using an Orcle thin driver.
    I know how to connect via a JDBCODBC bridge.
    Also Pls tell me of a suitable java oracle thin driver.

    Will this help?
    Oracle
    Driver Class Name
    oracle.jdbc.driver.OracleDriver
    JDBC URL
    jdbc:oracle:thin://hostname:port/schema_name
    Example
    jdbc:oracle:thin:@172.19.139.58:1521:UAT02
    SQL Server
    Driver Class Name
    com.microsoft.jdbc.sqlserver.SQLServerDriver
    JDBC URL
    jdbc:microsoft:sqlserver://hostname:port
    Example
    jdbc:microsoft:sqlserver://172.19.138.24:1433

  • JDBC Realm help

    Hi,
    I have been trying to get the JDBC Realm to work, but with no success,
    I get the following error:
    Catalina.start: LifecycleException: Exception opening database connection: java.sql.SQLException
    LifecycleException: Exception opening database connection: java.sql.SQLException
    (see bottom of page for more detail)
    I have successfully connected to the database and retrieved data using the following code
    // Define the JDBP Driver and the database connection URL
    public static final String driver = "org.gjt.mm.mysql.Driver";
    public static final String url = "jdbc:mysql://localhost/db?user=un&password=pw";
    public static void main(String args[])
    Connection conn;
    try
    Class.forName(driver); // load the driver dynamically
    conn = DriverManager.getConnection(url); // connect to the database
    // perform a query. first create a Statement object from the connection
    Statement select = conn.createStatement();
    // next execute a query (SQL string) and return the results in a ResultSet object
    ResultSet result = select.executeQuery("select * from users");
    // print out the results
    while(result.next())
    String user = result.getString("user_name"); // note these match the columns in the
    String password = result.getString("user_pass"); // SELECT statement
    System.out.println(user + " " + password);
    select.close(); //Close the query
    conn.close(); //Close the database connection
    however I have no luck in connecting using the JDBC Realm, I am using j2re1.4.1_01, jwsdp-1_0_01 & mysql-connector-java-3.1.0-alpha and the com & org directories are in $JWSDP_HOME/common/lib/ I have also put a copy of the mysql-connector-java-3.1.0-alpha.jar in $JWSDP_HOME/server/lib/ in an effort to get this to work!!
    my $JWSDP_HOME/conf/server.xml contains
    <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99" driver="org.gjt.mm.mysql.Driver"
    connectionURL="jdbc:mysql://localhost/db?user=un;password=pw"
    userTable="users" usserNameCol="user_name" userCredCol="user_pass"
    userRoleTable="user_roles" roleNameCol="role_name" />
    I hope someone can shed some light on this as I have been reading a lot of threads about this however they all seem to have the driver name included in the Exception error and I don't get that in the error message, so I am assuming that the driver is working and there is another error.....
    Cheers in advance
    Contentents of $JWSDP_HOME/logs/catalina.outStarting service Internal Services
    Java Web Services Developer Pack/1.0_01-fcs
    Catalina.start: LifecycleException: Exception opening database connection: java.sql.SQLException
    LifecycleException: Exception opening database connection: java.sql.SQLException
    at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:683)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1175)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347)
    at org.apache.catalina.core.StandardService.start(StandardService.java:499)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:2187)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:504)
    at org.apache.catalina.startup.Catalina.execute(Catalina.java:399)
    at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
    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.startup.Bootstrap.main(Bootstrap.java:203)
    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 com.sun.launcher.Launcher.main(Launcher.java:208)
    ----- Root Cause -----
    java.sql.SQLException
    at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:606)
    at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:681)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1175)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347)
    at org.apache.catalina.core.StandardService.start(StandardService.java:499)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:2187)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:504)
    at org.apache.catalina.startup.Catalina.execute(Catalina.java:399)
    at org.apache.catalina.startup.Catalina.process(Catalina.java:179)
    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.startup.Bootstrap.main(Bootstrap.java:203)
    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 com.sun.launcher.Launcher.main(Launcher.java:208)
    Stopping service Internal Services
    Catalina.stop: LifecycleException: Coyote connector has not been started
    LifecycleException: Coyote connector has not been started
    at org.apache.coyote.tomcat4.CoyoteConnector.stop(CoyoteConnector.java:1043)
    at org.apache.catalina.core.StandardService.stop(StandardService.java:549)
    at org.apache.catalina.core.StandardServer.stop(StandardServer.java:2223)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:535)
    at org.apache.catalina.startup.Catalina.execute(Catalina.java:399)
    logs/catalina.out

    okayyyy.... now i got ur point. I think its not much
    difficult. Lets take it step-by-step.
    That's what I thought and it's still not working .....
    As a first step, you have to create 3 tables in your
    mySql database for authentication purposes. Lets name
    those tables: (1) user, (2) roles (3) user_roles.
    'user' will contain fields regarding user name and
    password, 'roles' will contain only 1 field specific
    to role names and finally 'user_roles' is a mapping
    table which contain user names and their
    corresponding role names (obviously from 'roles'
    table). This completes the database in mySQL that
    will help you to authenticate your users.
    I have added the roles table, not that they are referenced in the JDBC Realm connector ????
    >
    Now, its time to configure your web container, i.e.
    Tomcat to use this database (in terms of JDBCRealm).
    Make sure that tomcat services are stopped and then
    open server.xml file in any ANSII compliant editor.
    Search for any real tag (<Realm ... ) already placed
    in your xml file. If there would be any, then you
    should find under the <Engine> tag. Now place your own
    <Realm> tag under the <Engine> tag.
    It should be something like:
    <Realm className="org.apache.catalina.realm.JDBCRealm"
    debug="99"
    driverName="org.gjt.mm.mysql.Driver"
    connectionURL="jdbc:mysql://localhost:3306/tomcatusers"
    connectionName="root"
    connectionPassword=""
    userTable="users"
    userNameCol="user_name"
    userCredCol="user_pass"
    userRoleTable="user_roles"
    roleNameCol="role_name"/>
    Yup already done... now slightly modified
    >
    Plz double check "connectionName" and
    "connectionPassword" attributes to match your own
    user-name and passwords for your mySql db. This will
    complete the whole process, just start your Tomcat
    services again and see if that work. I hope it will
    help you, plz must tell me about progress -:)
    Raheel.
    mysql -u tomcat -p
    mysql> select a.user_name, b.role_name from users a, user_roles b
    -> where a.user_name=b.user_name;
    ----------------------+
    | user_name | role_name |
    ----------------------+
    | daren | employee |
    | tomcat | admin |
    | tomcat | manager |
    | tomcat | provider |
    ----------------------+
    can you guess what happened????
    IT DONT WORK :(

  • MySQL -- JDBC Connection help !!!

    Hi everybody...Well I have MySQL Server and Java, I get the JDBC and tried this:
    import java.sql.*;
    public class JdbcE {
    public static void main(String args[]) {
    Connection con = null;
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql://localhost/test", "user", "pass");
    if(!con.isClosed())
    System.out.println("Successfully connected to MySQL server...");
    } catch(Exception e) {
    System.err.println("Exception: " + e.getMessage());
    } finally {
    try {
    if(con != null)
    con.close();
    } catch(SQLException e) {}
    And with that code all works fine...but when I change the Host from LOCALHOST to [ROUTER IP] like this:
    con = DriverManager.getConnection("jdbc:mysql://182.185.145.12/test", "user", "pass");
    I got this exception:
    Exception: Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.net.SocketException
    MESSAGE: java.net.ConnectException: Connection timed out: connect
    STACKTRACE:
    java.net.SocketException: java.net.ConnectException: Connection timed out: conne
    ct
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
    va:156)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2666)
    at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
    :266)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at JdbcE.main(JdbcE.java:11)
    ** END NESTED EXCEPTION **
    Last packet sent to the server was 16 ms ago.
    I don't know how to solve it...
    I have a 2wire 1700HG router, maybe it would be a problem of the firewall can anyone help me to solve this problem??

    Well I sorry...I am very new in this kind of things...I just know that I have a 2wire 1700HG, I have installed MySQL Server, Java and mysql-connector-java...
    When I try this in the connection statement:
    con = DriverManager.getConnection("jdbc:mysql://localhost/test", "user", "test");
    Everything works fine...but when I try this to connect from a remote PC
    con = DriverManager.getConnection("jdbc:mysql://189.145.185.182/test", "user", "test");
    This error comes out on screen:
    Exception: Communications link failure due to underlying exception:
    ** BEGIN NESTED EXCEPTION **
    java.net.SocketException
    MESSAGE: java.net.ConnectException: Connection timed out: connect
    STACKTRACE:
    java.net.SocketException: java.net.ConnectException: Connection timed out: conne
    ct
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
    va:156)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2666)
    at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
    :266)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at JdbcE.main(JdbcE.java:11)
    ** END NESTED EXCEPTION **
    Last packet sent to the server was 16 ms ago.
    I don't know what can I do :S please help!! :D

  • JDBC Driver (HELP NEEDED URGENTLY)

    Hi, I'm a student who has a project to be done on java.
    I would like to use access or some other db tt is plafform independence.
    However, I do not know of such a dbms system. Can someone help me by telling me with access can be used on other plafform or there is a better dbms out there?
    Also , is there any way the client can just do installation without using jdbc to odbc bridge as the installion of the application should be easy and do not require the client to do install addition stuff or trouble themselve over the installtion of the software. Your help is greatly needed Thank you.

    I assume you meant "db that is platform independent."
    Try http://postgresql.org or http://mysql.org. Both
    are free, open source and well supported. And nearly
    anything is 'better' than Access. Not sure about the
    second part of your query.Message:
    Thanks for the tip man. The second problem i have is that i m trying to create a program that run on stand alone PC . It must be able to access a database. However, using the odbc bridge means that it is not plafform indepence while is one of the aim i have for the program. Is it possible to find a driver that dont need to the odbc and can run on standalone PC without a server between there?
    thanks you for all your help!!!

  • "com.mysql.jdbc.PacketTooBigException": Help needed urgently

    hi,
    I am using mm.mysql j/connector ver 3.0.6 and MYSQL server version 4.0.
    Max_allowed packet= 8MB at the server side
    I am getting PacketTooBigException when i am trying to update a particular column.
    What should i do.
    Any help will be greatly appreciated!!!

    the driver uses a 64 k max packet size by default. it is supposed to change this as neccessary upon connection but perhaps that is failing?
    below is the 3.0.7 connection code that i have slightly modified for you so that it prints out the connection properties after they have been initialized so that you can see what they are.
    try it out and i hope you find this helpful.
       Copyright (C) 2002 MySQL AB
          This program is free software; you can redistribute it and/or modify
          it under the terms of the GNU General Public License as published by
          the Free Software Foundation; either version 2 of the License, or
          (at your option) any later version.
          This program is distributed in the hope that it will be useful,
          but WITHOUT ANY WARRANTY; without even the implied warranty of
          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
          GNU General Public License for more details.
          You should have received a copy of the GNU General Public License
          along with this program; if not, write to the Free Software
          Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    /*Slight Modification by Max Stocker April 29, 2003 to trace what the connection values get initialized to. */
    package com.mysql.jdbc;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.Reader;
    import java.io.UnsupportedEncodingException;
    import java.math.BigDecimal;
    import java.net.URL;
    import java.sql.Clob;
    import java.sql.Date;
    import java.sql.ParameterMetaData;
    import java.sql.Ref;
    import java.sql.SQLException;
    import java.sql.Savepoint;
    import java.sql.Time;
    import java.sql.Timestamp;
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    import java.util.Properties;
    import java.util.StringTokenizer;
    import java.util.TimeZone;
    * A Connection represents a session with a specific database.  Within the
    * context of a Connection, SQL statements are executed and results are
    * returned.
    * <P>A Connection's database is able to provide information describing
    * its tables, its supported SQL grammar, its stored procedures, the
    * capabilities of this connection, etc.  This information is obtained
    * with the getMetaData method.
    * @see java.sql.Connection
    * @author Mark Matthews
    * @version $Id: Connection.java,v 1.31.2.19 2003/03/28 22:42:24 mmatthew Exp $
    public class Connection implements java.sql.Connection {
        // The command used to "ping" the database.
        // Newer versions of MySQL server have a ping() command,
        // but this works for everything
        private static final String PING_COMMAND = "SELECT 1";
         * Map mysql transaction isolation level name to
         * java.sql.Connection.TRANSACTION_XXX
        private static Map mapTransIsolationName2Value = null;
         * The mapping between MySQL charset names
         * and Java charset names.
         * Initialized by loadCharacterSetMapping()
        private static Map charsetMap;
         * Table of multi-byte charsets.
         * Initialized by loadCharacterSetMapping()
        private static Map multibyteCharsetsMap;
         * Default socket factory classname
        private static final String DEFAULT_SOCKET_FACTORY = StandardSocketFactory.class
            .getName();
        static {
            loadCharacterSetMapping();
            mapTransIsolationName2Value = new HashMap(8);
            mapTransIsolationName2Value.put("READ-UNCOMMITED",
                new Integer(TRANSACTION_READ_UNCOMMITTED));
              mapTransIsolationName2Value.put("READ-UNCOMMITTED",
                   new Integer(TRANSACTION_READ_UNCOMMITTED));
            mapTransIsolationName2Value.put("READ-COMMITTED",
                new Integer(TRANSACTION_READ_COMMITTED));
            mapTransIsolationName2Value.put("REPEATABLE-READ",
                new Integer(TRANSACTION_REPEATABLE_READ));
            mapTransIsolationName2Value.put("SERIALIZABLE",
                new Integer(TRANSACTION_SERIALIZABLE));
         * Internal DBMD to use for various database-version
         * specific features
        private DatabaseMetaData dbmd = null;
         * The list of host(s) to try and connect to
        private List hostList = null;
          * A map of statements that have had setMaxRows() called on them
         private Map statementsUsingMaxRows;
         * The I/O abstraction interface (network conn to
         * MySQL server
        private MysqlIO io = null;
         * Mutex
        private final Object mutex = new Object();
         * The driver instance that created us
        private NonRegisteringDriver myDriver;
         * The map of server variables that we retrieve
         * at connection init.
        private Map serverVariables = null;
         * Properties for this connection specified by user
        private Properties props = null;
         * The database we're currently using
         * (called Catalog in JDBC terms).
        private String database = null;
         * If we're doing unicode character conversions,
         * what encoding do we use?
        private String encoding = null;
         * The hostname we're connected to
        private String host = null;
         * The JDBC URL we're using
        private String myURL = null;
         * The password we used
        private String password = null;
         * Classname for socket factory
        private String socketFactoryClassName = null;
         * The user we're connected as
        private String user = null;
         * The timezone of the server
        private TimeZone serverTimezone = null;
         * Allow LOAD LOCAL INFILE (defaults to true)
        private boolean allowLoadLocalInfile = true;
         * Are we in autoCommit mode?
        private boolean autoCommit = true;
         * Should we capitalize mysql types
        private boolean capitalizeDBMDTypes = false;
         * Should we continue processing batch commands if
         * one fails. The JDBC spec allows either way, so
         * we let the user choose
        private boolean continueBatchOnError = true;
         * Should we do unicode character conversions?
        private boolean doUnicode = false;
         * Are we failed-over to a non-master host
        private boolean failedOver = false;
        /** Does the server suuport isolation levels? */
        private boolean hasIsolationLevels = false;
         * Does this version of MySQL support quoted identifiers?
        private boolean hasQuotedIdentifiers = false;
        // This is for the high availability :) routines
        private boolean highAvailability = false;
         * Has this connection been closed?
        private boolean isClosed = true;
         * Should we tell MySQL that we're an interactive client?
        private boolean isInteractiveClient = false;
         * Is the server configured to use lower-case
         * table names only?
        private boolean lowerCaseTableNames = false;
         * Has the max-rows setting been changed from
         * the default?
        private boolean maxRowsChanged = false;
         * Do we expose sensitive information in exception
         * and error messages?
        private boolean paranoid = false;
         * Should we do 'extra' sanity checks?
        private boolean pedantic = false;
         * Are we in read-only mode?
        private boolean readOnly = false;
        /** Do we relax the autoCommit semantics? (For enhydra, for example) */
        private boolean relaxAutoCommit = false;
         * Do we need to correct endpoint rounding errors
        private boolean strictFloatingPoint = false;
         * Do we check all keys for updatable result sets?
        private boolean strictUpdates = true;
        /** Are transactions supported by the MySQL server we are connected to? */
        private boolean transactionsSupported = false;
         * Has ANSI_QUOTES been enabled on the server?
        private boolean useAnsiQuotes = false;
         * Should we use compression?
        private boolean useCompression = false;
         * Can we use the "ping" command rather than a
         * query?
        private boolean useFastPing = false;
         * Should we tack on @hostname in DBMD.getTable/ColumnPrivileges()?
        private boolean useHostsInPrivileges = true;
         * Should we use SSL?
        private boolean useSSL = false;
         * Should we use stream lengths in prepared statements?
         * (true by default == JDBC compliant)
        private boolean useStreamLengthsInPrepStmts = true;
         * Should we use timezone information?
        private boolean useTimezone = false;
        /** Should we return PreparedStatements for UltraDev's stupid bug? */
        private boolean useUltraDevWorkAround = false;
        private double initialTimeout = 2.0D;
         * How many hosts are in the host list?
        private int hostListSize = 0;
         * isolation level
        private int isolationLevel = java.sql.Connection.TRANSACTION_READ_COMMITTED;
         * The largest packet we can send (changed
         * once we know what the server supports, we
         * get this at connection init).
        private int maxAllowedPacket = 65536;
        private int maxReconnects = 3;
         * The max rows that a result set can contain.
         * Defaults to -1, which according to the JDBC
         * spec means "all".
        private int maxRows = -1;
        private int netBufferLength = 16384;
         * The port number we're connected to
         * (defaults to 3306)
        private int port = 3306;
         * How many queries should we wait before we try to re-connect
         * to the master, when we are failing over to replicated hosts
         * Defaults to 50
        private int queriesBeforeRetryMaster = 50;
         * What should we set the socket timeout to?
        private int socketTimeout = 0; // infinite
         * When did the last query finish?
        private long lastQueryFinishedTime = 0;
         * When did the master fail?
        private long masterFailTimeMillis = 0L;
         * Number of queries we've issued since the master
         * failed
        private long queriesIssuedFailedOver = 0;
         * How many seconds should we wait before retrying to connect
         * to the master if failed over? We fall back when either
         * queriesBeforeRetryMaster or secondsBeforeRetryMaster is
         * reached.
        private long secondsBeforeRetryMaster = 30L;
         * The type map for UDTs (not implemented, but used by
         * some third-party vendors, most notably IBM WebSphere)
        private Map typeMap;
         * Ignore non-transactional table warning for rollback?
        private boolean ignoreNonTxTables = false;
         * Creates a connection to a MySQL Server.
         * @param host the hostname of the database server
         * @param port the port number the server is listening on
         * @param info a Properties[] list holding the user and password
         * @param database the database to connect to
         * @param url the URL of the connection
         * @param d the Driver instantation of the connection
         * @exception java.sql.SQLException if a database access error occurs
        Connection(String host, int port, Properties info, String database,
            String url, NonRegisteringDriver d) throws java.sql.SQLException {
            if (Driver.TRACE) {
                Object[] args = { host, new Integer(port), info, database, url, d };
                Debug.methodCall(this, "constructor", args);
            this.serverVariables = new HashMap();
            hostList = new ArrayList();
            if (host == null) {
                this.host = "localhost";
                hostList.add(this.host);
            } else if (host.indexOf(",") != -1) {
                // multiple hosts separated by commas (failover)
                StringTokenizer hostTokenizer = new StringTokenizer(host, ",", false);
                while (hostTokenizer.hasMoreTokens()) {
                    hostList.add(hostTokenizer.nextToken().trim());
            } else {
                this.host = host;
                hostList.add(this.host);
            hostListSize = hostList.size();
            this.port = port;
            if (database == null) {
                throw new SQLException("Malformed URL '" + url + "'.", "S1000");
            this.database = database;
            this.myURL = url;
            this.myDriver = d;
            this.user = info.getProperty("user");
            this.password = info.getProperty("password");
            if ((this.user == null) || this.user.equals("")) {
                this.user = "nobody";
            if (this.password == null) {
                this.password = "";
            this.props = info;
            initializeDriverProperties(info);
            if (Driver.DEBUG) {
                System.out.println("Connect: " + this.user + " to " + this.database);
            try {
                createNewIO(false);
                this.dbmd = new DatabaseMetaData(this, this.database);
            } catch (java.sql.SQLException ex) {
                cleanup();
                // don't clobber SQL exceptions
                throw ex;
            } catch (Exception ex) {
                cleanup();
                StringBuffer mesg = new StringBuffer();
                if (!useParanoidErrorMessages()) {
                    mesg.append("Cannot connect to MySQL server on ");
                    mesg.append(this.host);
                    mesg.append(":");
                    mesg.append(this.port);
                    mesg.append(".\n\n");
                    mesg.append("Make sure that there is a MySQL server ");
                    mesg.append("running on the machine/port you are trying ");
                    mesg.append(
                        "to connect to and that the machine this software is "
                        + "running on ");
                    mesg.append("is able to connect to this host/port "
                        + "(i.e. not firewalled). ");
                    mesg.append(
                        "Also make sure that the server has not been started "
                        + "with the --skip-networking ");
                    mesg.append("flag.\n\n");
                } else {
                    mesg.append("Unable to connect to database.");
                mesg.append("Underlying exception: \n\n");
                mesg.append(ex.getClass().getName());
                throw new java.sql.SQLException(mesg.toString(), "08S01");
         * If a connection is in auto-commit mode, than all its SQL
         * statements will be executed and committed as individual
         * transactions.  Otherwise, its SQL statements are grouped
         * into transactions that are terminated by either commit()
         * or rollback().  By default, new connections are in auto-
         * commit mode.  The commit occurs when the statement completes
         * or the next execute occurs, whichever comes first.  In the
         * case of statements returning a ResultSet, the statement
         * completes when the last row of the ResultSet has been retrieved
         * or the ResultSet has been closed.  In advanced cases, a single
         * statement may return multiple results as well as output parameter
         * values.  Here the commit occurs when all results and output param
         * values have been retrieved.
         * <p><b>Note:</b> MySQL does not support transactions, so this
         *                 method is a no-op.
         * @param autoCommit - true enables auto-commit; false disables it
         * @exception java.sql.SQLException if a database access error occurs
        public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException {
            if (Driver.TRACE) {
                Object[] args = { new Boolean(autoCommit) };
                Debug.methodCall(this, "setAutoCommit", args);
            checkClosed();
            if (this.transactionsSupported) {
                // this internal value must be set first as failover depends on it
                // being set to true to fail over (which is done by most
                // app servers and connection pools at the end of
                // a transaction), and the driver issues an implicit set
                // based on this value when it (re)-connects to a server
                // so the value holds across connections
                this.autoCommit = autoCommit;
                String sql = "SET autocommit=" + (autoCommit ? "1" : "0");
                execSQL(sql, -1, this.database);
            } else {
                if ((autoCommit == false) && (this.relaxAutoCommit == false)) {
                    throw new SQLException("MySQL Versions Older than 3.23.15 "
                        + "do not support transactions", "08003");
                } else {
                    this.autoCommit = autoCommit;
            return;
         * gets the current auto-commit state
         * @return Current state of the auto-commit mode
         * @exception java.sql.SQLException (why?)
         * @see setAutoCommit
        public boolean getAutoCommit() throws java.sql.SQLException {
            if (Driver.TRACE) {
                Object[] args = new Object[0];
                Debug.methodCall(this, "getAutoCommit", args);
                Debug.returnValue(this, "getAutoCommit",
                    new Boolean(this.autoCommit));
            return this.autoCommit;
         * A sub-space of this Connection's database may be selected by
         * setting a catalog name.  If the driver does not support catalogs,
         * it will silently ignore this request
         * <p><b>Note:</b> MySQL's notion of catalogs are individual databases.
         * @param catalog the database for this connection to use
         * @throws java.sql.SQLException if a database access error occurs
        public void setCatalog(String catalog) throws java.sql.SQLException {
            if (Driver.TRACE) {
                Object[] args = { catalog };
                Debug.methodCall(this, "setCatalog", args);
            checkClosed();
            String quotedId = this.dbmd.getIdentifierQuoteString();
            if ((quotedId == null) || quotedId.equals(" ")) {
                quotedId = "";
            StringBuffer query = new StringBuffer("USE ");
            query.append(quotedId);
            query.append(catalog);
            query.append(quotedId);
            execSQL(query.toString(), -1, catalog);
            this.database = catalog;
         * Return the connections current catalog name, or null if no
         * catalog name is set, or we dont support catalogs.
         * <p><b>Note:</b> MySQL's notion of catalogs are individual databases.
         * @return the current catalog name or null
         * @exception java.sql.SQLException if a database access error occurs
        public String getCatalog() throws java.sql.SQLException {
            if (Driver.TRACE) {
                Object[] args = new Object[0];
                Debug.methodCall(this, "getCatalog", args);
                Debug.returnValue(this, "getCatalog", this.database);
            return this.database;
         * DOCUMENT ME!
         * @return DOCUMENT ME!
        public boolean isClosed() {
            if (Driver.TRACE) {
                Object[] args = new Object[0];
                Debug.methodCall(this, "isClosed", args);
                Debug.returnValue(this, "isClosed", new Boolean(this.isClosed));
            return this.isClosed;
         * Returns the character encoding for this Connection
         * @return the character encoding for this connection.
        public String getEncoding() {
            return this.encoding;
         * @see Connection#setHoldability(int)
        public void setHoldability(int arg0) throws SQLException {
            // do nothing
         * @see Connection#getHoldability()
        public int getHoldability() throws SQLException {
            return ResultSet.CLOSE_CURSORS_AT_COMMIT;
         * NOT JDBC-Compliant, but clients can use this method
         * to determine how long this connection has been idle.
         * This time (reported in milliseconds) is updated once
         * a query has completed.
         * @return number of ms that this connection has
         * been idle, 0 if the driver is busy retrieving results.
        public long getIdleFor() {
            if (this.lastQueryFinishedTime == 0) {
                return 0;
            } else {
                long now = System.currentTimeMillis();
                long idleTime = now - this.lastQueryFinishedTime;
                return idleTime;
         * Should we tell MySQL that we're an interactive client
         * @return true if isInteractiveClient was set to true.
        public boolean isInteractiveClient() {
            return isInteractiveClient;
         * A connection's database is able to provide information describing
         * its tables, its supported SQL grammar, its stored procedures, the
         * capabilities of this connection, etc.  This information is made
         * available through a DatabaseMetaData object.
         * @return a DatabaseMetaData object for this connection
         * @exception java.sql.SQLException if a database access error occurs
        public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException {
            checkClosed();
            return new DatabaseMetaData(this, this.database);
         * You can put a connection in read-only mode as a hint to enable
         * database optimizations
         * <B>Note:</B> setReadOnly cannot be called while in the middle
         * of a transaction
         * @param readOnly - true enables read-only mode; false disables it
         * @exception java.sql.SQLException if a database access error occurs
        public void setReadOnly(boolean readOnly) throws java.sql.SQLException {
            if (Driver.TRACE) {
                Object[] args = { new Boolean(readOnly) };
                Debug.methodCall(this, "setReadOnly", args);
                Debug.returnValue(this, "setReadOnly", new Boolean(readOnly));
            checkClosed();
            this.readOnly = readOnly;
         * Tests to see if the connection is in Read Only Mode.  Note that
         * we cannot really put the database in read only mode, but we pretend
         * we can by returning the value of the readOnly flag
         * @return true if the connection is read only
         * @exception java.sql.SQLException if a database access error occurs
        public boolean isReadOnly() throws java.sql.SQLException {
            if (Driver.TRACE) {
                Object[] args = new Object[0];
                Debug.methodCall(this, "isReadOnly", args);
                Debug.returnValue(this, "isReadOnly", new Boolean(this.readOnly));
            return this.readOnly;
         * @see Connection#setSavepoint()
        public java.sql.Savepoint setSavepoint() throws SQLException {
            throw new NotImplemented();
         * @see Connection#setSavepoint(String)
        public java.sql.Savepoint setSavepoint(String arg0)
            throws SQLException {
            throw new NotImplemented();
         * DOCUMENT ME!
         * @return DOCUMENT ME!
        public TimeZone getServerTimezone() {
            return this.serverTimezone;
         * DOCUMENT ME!
         * @param level DOCUMENT ME!
         * @throws java.sql.SQLException DOCUMENT ME!
        public void setTransactionIsolation(int level) throws java.sql.SQLException {
            if (Driver.TRACE) {
                Object[] args = { new Integer(level) };
                Debug.methodCall(this, "setTransactionIsolation", args);
            checkClosed();
            if (this.hasIsolationLevels) {
                StringBuffer sql = new StringBuffer(
                        "SET SESSION TRANSACTION ISOLATION LEVEL ");
                switch (level) {
                case java.sql.Connection.TRANSACTION_NONE:
                    throw new SQLException("Transaction isolation level "
                        + "NONE not supported by MySQL");
                case java.sql.Connection.TRANSACTION_READ_COMMITTED:
                    sql.append("READ COMMITTED");
                    break;
                case java.sql.Connection.TRANSACTION_READ_UNCOMMITTED:
                    sql.append("READ UNCOMMITTED");
                    break;
                case java.sql.Connection.TRANSACTION_REPEATABLE_READ:
                    sql.append("REPEATABLE READ");
                    break;
                case java.sql.Connection.TRANSACTION_SERIALIZABLE:
                    sql.append("SERIALIZABLE");
                    break;
                default:
                    throw new SQLException("Unsupported transaction "
                        + "isolation level '" + level + "'", "S1C00");
                execSQL(sql.toString(), -1, this.database);
                isolationLevel = level;
            } else {
                throw new java.sql.SQLException("Transaction Isolation Levels are "
                    + "not supported on MySQL versions older than 3.23.36.", "S1C00");
         * Get this Connection's current transaction isolation mode.
         * @return the current TRANSACTION_* mode value
         * @exception java.sql.SQLException if a database access error occurs
        public int getTransactionIsolation() throws java.sql.SQLException {
            if (Driver.TRACE) {
                Object[] args = new Object[0];
                Debug.methodCall(this, "getTransactionIsolation", args);
                Debug.returnValue(this, "getTransactionIsolation",
                    new Integer(isolationLevel));
            if (this.hasIsolationLevels) {
                 java.sql.Statement stmt = null;
                 java.sql.ResultSet rs = null;
                 try {
                      stmt = this.createStatement();
                      String query = null;
                      if (this.io.versionMeetsMinimum(4, 0, 3)) {
                           query = "SHOW VARIABLES LIKE 'tx_isolation'";
                      } else {
                           query = "SHOW VARIABLES LIKE 'transaction_isolation'";
                      rs = stmt.executeQuery(query);
                      if (rs.next()) {
                           String s = rs.getString(2);
                           if (s != null) {
                                  Integer intTI = (Integer) mapTransIsolationName2Value.get(s);
                                  if (intTI != null) {
                                       return intTI.intValue();
                           throw new SQLException("Could not map transaction isolation '" + s + " to a valid JDBC level.", "S1000");
                      } else {
                           throw new SQLException("Could not retrieve transaction isolation level from server", "S1000");
                 } finally {
                      if (rs != null) {
                           try {
                                rs.close();
                           } catch (Exception ex) {
                                // ignore
                           rs = null;
                      if (stmt != null) {
                           try {
                                stmt.close();
                           } catch (Exception ex) {
                                // ignore
                           stmt = null;
            return isolationLevel;
         * JDBC 2.0
         * Install a type-map object as the default type-map for
         * this connection
         * @param map the type mapping
         * @throws SQLException if a database error occurs.
        public void setTypeMap(java.util.Map map) throws SQLException {
            this.typeMap = map;
         * JDBC 2.0
         * Get the type-map object associated with this connection.
         * By default, the map returned is empty.
         * @return the type map
         * @throws SQLException if a database error occurs
        public synchronized java.util.Map getTypeMap() throws SQLException {
            if (this.typeMap == null) {
                this.typeMap = new HashMap();
            return this.typeMap;
         * The first warning reported by calls on this Connection is
         * returned.
         * <B>Note:</B> Sebsequent warnings will be changed to this
         * java.sql.SQLWarning
         * @return the first java.sql.SQLWarning or null
         * @exception java.sql.SQLException if a database access error occurs
        public java.sql.SQLWarning getWarnings() throws java.sql.SQLException {
            if (Driver.TRACE) {
                Object[] args = new Object[0];
                Debug.methodCall(this, "getWarnings", args);
                Debug.returnValue(this, "getWarnings", null);
            return null;
         * Allow use of LOAD LOCAL INFILE?
         * @return true if allowLoadLocalInfile was set to true.
        public boolean allowLoadLocalInfile() {
            return this.allowLoadLocalInfile;
         * DOCUMENT ME!
         * @return DOCUMENT ME!
        public boolean capitalizeDBMDTypes() {
            return this.capitalizeDBMDTypes;
         * After this call, getWarnings returns null until a new warning
         * is reported for this connection.
         * @exception java.sql.SQLException if a database access error occurs
        public void clearWarnings() throws java.sql.SQLException {
            if (Driver.TRACE) {
                Object[] args = new Object[0];
                Debug.methodCall(this, "clearWarnings", args);
            // firstWarning = null;
         * In some cases, it is desirable to immediately release a Connection's
         * database and JDBC resources instead of waiting for them to be
         * automatically released (                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

  • How to use % wildcard in jdbc plz help me

    Hello all,
    try
         PreparedStatement st=dbcon.prepareStatement("select * from stud2  where ename=? ");
    st.setString(1,ename+"%");
    ResultSet rs=st.executeQuery();
    while(rs.next())
    out.println("<td>");
    out.println(rs.getString(2));//this field is for name
    out.println(rs.getString(3));//this is for addresss
    }catch(Exception e){}This code is in servlets,and iam using MS-ACCESS as database.
    in this way iam trying this code , usage of %wild card but iam not getting the right anser, i want the anser if i will type any letter it should search the database and display me all names of that letter
    plz help me solving this problem
    vidya.

    PreparedStatement ps = con.prepareStatement("select blah from blah where blah like ?");
    ps.setString(1, "a%"); // everything that starts with 'a'
    rs = ps.executeQuery();

  • [b]Connection to Oracle DB per JDBC URGENT HELP NEEDED PLEASE![/b]

    Hallo,
    I'm a newbie. I want to make a connection to the oracle db on the server and I have been having serious problems. See CODE and ERROR MESSAGEs below:
    import java.sql.*;
    public class SqlConnection01 {
         public static void main(String[] args) {
              Connection con = null;
              Statement stmt = null;
              try {
                   Class.forName("oracle.jdbc.driver.OracleDriver"); //Loading the Oracle Driver.
    con = DriverManager.getConnection
         ("jdbc:oracle:thin:@38.218.2.227:1521:testdb","data","test"); //making the connection.
                   stmt = con.createStatement ();// Sending a query to the database
                   ResultSet rs = stmt.executeQuery("SELECT mand,kost,ktest,kok FROM test");
                        while (rs.next()) {
                             String mandt = rs.getString("1");
                             String kostl = rs.getString("2");
                             String ktest = rs.getString("3");
                             String kokrs = rs.getString("4");
                             System.out.println( mandt + kostl ktest kokrs );
              } catch(Exception e) {
                   e.printStackTrace();
              } finally {
                   try
                        if(stmt != null) stmt.close();
                        if(con != null) con.close();
                   } catch (Exception exception) {
                        exception.printStackTrace();
    ERROR MESSAGE:
    java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
         at oracle.jdbc.ttc7.TTC7Protocol.handleIOException(TTC7Protocol.java:3695)
         at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:352)
         at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:362)
         at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:536)
         at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:328)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at SqlConnection01.main(SqlConnection01.java:24)
    What am I doing wrong here. I am using Oracle9i client installed on my pc (Release 2 (9.2.0.1.0) for Windows ) so I downloaded the ojdbc14 drivers for this version and I copied them in my bin directory C:\j2sdk1.4.2_06\bin\ojdbc14 .
    Secondly I can connect to the db per command line( sqlplus /nolog; conn data/test@testdb) and querry the testdb.
    I can also test the connection using oracle Net Manager and the test is successful.
    But I can't start up the lsnrctl on my pc.I get this message any time i issue the command(C:\>lsnrctl
    'lsnrctl' is not recognized as an internal or external command, operable program or batch file.)
    What am I doing wrong here? What should I do to have this connection possible. Thanks very much in advance.

    oh sure! Below is the TNSNAMES I copied from my PCfound in(C:\oracle\ora92\network\admin\SAMPLE) The next thing could be how could I get access to the TNSNAMES on the server?
    STARTS HERE:
    <alias>= [ (DESCRIPTION_LIST =  # Optional depending on whether u have
                        # one or more descriptions
                        # If there is just one description, unnecessary ]
         (DESCRIPTION=
         [ (SDU=2048) ]     # Optional, defaults to 2048
                        # Can take values between 512 and 32K
         [ (ADDRESS_LIST=    # Optional depending on whether u have
                        # one or more addresses
                        # If there is just one address, unnecessary ]
         (ADDRESS=
              [ (COMMUNITY=<community_name>) ]
              (PROTOCOL=tcp)
              (HOST=<hostname>)
              (PORT=<portnumber (1521 is a standard port used)>)
         [ (ADDRESS=
              (PROTOCOL=ipc)
              (KEY=<ipckey (PNPKEY is a standard key used)>)     
         [ (ADDRESS=
              [ (COMMUNITY=<community_name>) ]
              (PROTOCOL=decnet)
              (NODE=<nodename>)
              (OBJECT=<objectname>)
    ... # More addresses
         [ ) ] # Optional depending on whether ADDRESS_LIST is used or not
         [ (CONNECT_DATA=
              (SID=<oracle_sid>)
              [ (GLOBAL_NAME=<global_database_name>) ]
         [ (SOURCE_ROUTE=yes) ]
         (DESCRIPTION=
         [ (SDU=2048) ]     # Optional, defaults to 2048
                        # Can take values between 512 and 32K
         [ (ADDRESS_LIST= ]     # Optional depending on whether u have more
                        # than one address or not
                        # If there is just one address, unnecessary
         (ADDRESS
              [ (COMMUNITY=<community_name>) ]
              (PROTOCOL=tcp)
              (HOST=<hostname>)
              (PORT=<portnumber (1521 is a standard port used)>)
         [ (ADDRESS=
              (PROTOCOL=ipc)
              (KEY=<ipckey (PNPKEY is a standard key used)>)
         ...           # More addresses
         [ ) ]           # Optional depending on whether ADDRESS_LIST
                        # is being used
         [ (CONNECT_DATA=
              (SID=<oracle_sid>)
              [ (GLOBAL_NAME=<global_database_name>) ]
         [ (SOURCE_ROUTE=yes) ]
         [ (CONNECT_DATA=
         (SID=<oracle_sid>)
         [ (GLOBAL_NAME=<global_database_name>) ]
         ... # More descriptions
         [ ) ]     # Optional depending on whether DESCRIPTION_LIST is used or not
    I think this is the example of what is in the TNSNAMES. It hasn't got the infos I need here.It just explain.

  • RFC-XI-JDBC Scenario: Help with RFC code

    HI,
    I am doing RFC-XI-JDBC Scenario, where I have to poll the contents of my Ztable in SAP to Oracle.
    The appraoach i am using here is :
    1. Created a FM with import parameters as the fields of my Ztable and without any  export parameter or source code.
    2. Created a report to call that FM in background. The code of my report is as follows :
    ************************REPORT***********************************************************
    Data:       it_zrfc_read_table type table of zrfc_read_table,
                wa_zrfc_read_table like line of it_zrfc_read_table.
    PARAMETERS: tab_name like DD02L-TABNAME.
    Data:       l_tabname type DD02L-TABNAME.
    At selection-screen.
    select single tabname from DD02L into l_tabname  where tabname = tab_name.
    if sy-subrc <> 0.
      message 'incorrect table name' type 'E'.
    endif.
    start-of-selection.
    select * from (tab_name) into corresponding fields of table it_zrfc_read_table.
    loop at it_zrfc_read_table into wa_zrfc_read_table.
    CALL FUNCTION 'ZRFC_READ_TABLE2XI'
    IN BACKGROUND TASK DESTINATION 'ORACLEGIS_RFC_SENDER'
      EXPORTING
        valve_id       = wa_zrfc_read_table-valve_id
        equnr          = wa_zrfc_read_table-equnr
        ernam          = wa_zrfc_read_table-ernam
        invnr          = wa_zrfc_read_table-invnr
        groes          = wa_zrfc_read_table-groes
        elief          = wa_zrfc_read_table-elief
        gwlen          = wa_zrfc_read_table-gwlen
        gwldt          = wa_zrfc_read_table-gwldt
        serge          = wa_zrfc_read_table-serge
        typbz          = wa_zrfc_read_table-typbz.
        endloop.
        commit work.
    NOw my problem is that although I am able to send a table with a single record, but when my records > 1, it is not able to poll.
    Please guide me what can be altered in the code or any other suggestion.
    Thanks,
    Puneet

    Hi,
    Instead of calling RFC many times I would:
    1) create RFM with only one import parameter
    TYPE your_table type
    2) call only once RFM in the report:
      CALL FUNCTION 'ZRFCNAME'
        IN BACKGROUND TASK
        DESTINATION 'RFCDEST'
        EXPORTING
          pt_table = i_table.
      COMMIT WORK AND WAIT.
    This will also improve the performance.
    Regards,
    Jakub

  • JDBC connector help

    Ok here we go,
    I want to work with MySQL and JSP from Dreamweaver . I installed TOMCAT 5.0 and everything is working fine. But... I can't connect to my MySQL. I have downloaded the connector from MySQL, Install it and here is my
    CLASSPATH : C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar;C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\jsp-api.jar;C:\Program Files\MySQL\MySQL Server 4.1\mysql-connector-java-3.1.5-bin.jar;
    When I try to connect I get the no suitable driver message. Can anybody help!!
    Thanks.
    Kriegerman

    It would help others to help you if you were to post the relevant code and specify the line of code that is generating the exception. This is because the message "No suitable driver" does not necessarily mean that the driver class could not be loaded. Indeed it may be that your URL is incorrect.

Maybe you are looking for

  • IPhoto does not ask to use Photo, Can't import

    I option created a new library and location for Photos on an external drive from my Aperture library. Most of the photos/projects and folders are not visible. It will also not let me import from my iPhoto library now that the new Photos library is cr

  • How to add multipleitunes accounts

    in the past I have opened several new iTunes accounts with different passwords for different Apple devices. Today I know, I could have just used one, but then I was very confused. i Know wish acces to all my itunes purchases from all my accounts, how

  • Problems generating right CSR for Callmanager 10 - cisco messes up values, Bug?

    Hi, we wanted to install our official SSL certificates for the Callmanager, presence and Unity Connection. I had to regenerate the web-security from the console following the instructions. All values are in the correct order: orgunit orgname locality

  • 6368 on board video

    I have been reading all the topics herein regarding disableing the on-board video for the 6368 V2 - my problem is this - I have changed the video from AGP to PCI and installed a new video card - when I reboot the computer it comes to Installing Stand

  • Quicktime plugin in Safari on iPhone

    I am able to view my security cameras over the internet from the Digital Video Recorder which is connect to my router. The inbuilt DVR application uses Quicktime to display the video and this works well on any PC. However, while the iPhone and iPad c