Basic JDBC usage

Hi,
I am writing a simple java program to access an oracle database. I have a piece of code:
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection c = DriverManager.getConnection("jdbc:oracle:thin:@ank:1521:usedb","arc","pass");
} catch (ClassNotFoundException ...
It compiles good but giving me an exception on running at the line Connection c = DriverManager ... :
Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/Savepoint
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:493)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
Does any one have any idea what I have done wrong?
thanks

My hunch is that you're not using the appropriate version of the JDBC driver for the version of the JDK you're using. If you use a 1.4 JDK, for example, you need to use the version of the JDBC driver for the 1.4 JDK, ojdbc14.jar.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • JDBC Usage - Managing Connections

    Hi:
    I'm not a Java Guru, I'm a rookie... so here it goes:
    For developing my JSP apps to generate XML to my wireless apps I use this kind of instructions:
    Class.forName("oracle.jdbc.driver.OracleDriver");
    String url_qry = "jdbc:oracle:thin:@193.136.231.151:1521:neo";
    String query_qry = "";
    query_qry = "select * from clientes where cod_cliente = 1"
    Connection conn_qry = DriverManager.getConnection(url_qry, p_username, p_password);
    Statement stmt_qry = conn_qry.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
    ResultSet rset_qry = stmt_qry.executeQuery(query_qry);
    rset_qry.absolute( 1 );
    %>
    .... my xml or html
    <%
         rset_qry.close();
         stmt_qry.close();
         conn_qry.close();
    %>
    My question is... Why my OC4J container shows always a high number of connections and the number of connections never shrink? I'm the only user to use these apps. So, Even if I use the close() methods the JDBC Usage in OC4J shows always growing numbers and never shrink...
    Thanks

    Hi Joao,
    This is only a guess, but OC4J uses a database connection pool, so this is probably why you are seeing a large number of connections.
    You can configure the size of the OC4J connection pool.
    Have you read the OC4J documentation, or tried asking this question in the OC4J forum, or looked at the code samples from the "Technet" Web site?
    http://technet.oracle.com/tech/java/oc4j/content.html
    Hope this helps you.
    Good Luck,
    Avi.

  • Diagnostics Profiling JDBC usage and leak problem

    Hi:
    Currently, I running diagnostics profiling JDBC usage and leak on my four Managed servers. It is collecting data for few hours, then it stop collecting data. Do anyone know why? How can I get it back to collecting data? Thank You

    Hello,
    Sorry you're having trouble...could you provide a bit more information as to your configuration, and how you are enabling JDBC profiling?
    Specifically:
    - What version of the server are you using?
    - Are you using the JDBC profiling hooks, or do you mean that you are using WLDF JDBC Instrumentation Monitors?
    - Are you saying that you're experiencing leaks because of this issue, or that you are using the profiling functionality to debug a potential leak?
    If you have WLDF configured, can you post your WLDF System Resource descriptor? It's located in <domain-dir>/config/diagnostics.
    Thanks,
    Mike

  • What Mac should I get for basic Photoshop usage?

    I'm hoping to tap into the vast resources/opinions here.
    I'm planning to get a Mac for my office. It will be use primarily for basic Photoshop usage. Maybe making some movies from iPhoto. The other usage would be normal ones like web surfing.
    Please suggest a desktop Mac first, and a laptop Mac 2nd.
    Which Mac model would be most cost-effective and doesn't need upgrading every year?
    Thanks a lot!
    Mavis

    Mavis, the answer to your question really depends on what you mean by 'basic' Photoshop use.
    Bearing in mind that Photoshop has been used by professionals in graphics and design houses for many years, typically working on hardware that is substantially less powerfull than a Mac mini, there is no reason to beleieve that even the entry-level Mac can't sucessfully be used for this kind of work, and those who suggest otherwise simply haven't tried it. However, there are some things that you need to keep in mind when using this software: the first is that Photoshop runs better the more memory you have, the second is that Photoshop files can require large amounts of storage, and the third is that the most recent version tends to place heavy demand on the processor - meaning that the faster the processor the better it runs.
    Thus, any Mac you buy for Photoshop use should ideally be equipped with 1Gb RAM rather than any less. You should also consider getting either the largest internal hard drive you can, or an external firewire drive for extra file storage.
    A Mac mini with 1.42GHz processor and a 1Gb RAM upgrade would certainly be sufficient, even for fairly demanding Photoshop work. The internal 80Gb drive for that model would give you a reasonable amount of space for files, though you would be wise to add a larger external drive too if the work you are doing is at all crucial. The same system would also be capable of your iPhoto work too. If your use is more casual, then the 1.25GHz mini would be enough, but again you'd need the 1Gb RAM upgrade.
    If your intended use is more at the commercial end of Photoshop use, then the chances are that even though a mini would be sufficient, you'd be better with an iMac or G5 tower, simply because for pro-level work, these systems are faster and permit smoother and more productive workflow.
    It also has to be said that no Mac will need upgrading each year, unless your level of use or your needs of that system change dramatically. A system you buy today will remain just as functional into the future. In other words, the best way to minimize the risk of having to upgrade in the forseable future is to work out exactly what you want the system for and buy a system that meets your present (and projected future) needs.

  • Basic JDBC Question

    Okay, I think this isn't supposed to be in this forum (Seeing as how there's a JDBC forum and all..), but this is so basic and I'm kicking myself over it I thought I'd put it in here. Anyways:
    I just installed mysql-connector-java-2.0.14, or at least I think I did. I keep getting the "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver" error. I read a lot of the forum hits I got for the error, but none of them helped me out...
    My JDK (I'm using 1.3.1_06 for compatibility reasons) is installed to /usr/java/jdk
    I'm compiling an applet on one machine, but hosting it off another. The applet must then be viewed by the compiling machine, the hosting machine, and any other machines (which I do not have access to).
    My question is this: What the hell am I doing wrong. :) Am I not understanding applets right? Does the client viewing it have to have the mysql driver installed? Does the server need it? I would assume only the compiling computer would...
    And if I only need it on the compiling machine, what am I doing wrong? My environmental variables are set as shown, I'm compiling with the shown command, and the code snippets are from my stuff. Parts in bold are what I feel is relevent (in the paths). God I feel like an idiot...
    Thanks in advance, and sorry to waste your time...
    echo $PATH
    /bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/home/jcourts/bin:/usr/java/jdk/bin:/usr/java/jdk/jre/lib/ext:/usr/java/jdk/jre/lib/ext/mysql-connector-java-2.0.14-bin.jar
    echo $CLASSPATH
    /usr/java/jdk/jre/lib/ext:/usr/java/jdk/jre/lib/ext/mysql-connector-java-2.0.14-bin.jar
    echo $JAVA_HOME
    /usr/java/jdk
    /usr/java/jdk/bin/javac -g -deprecation *.java
    import java.sql.*;
    -and-
    Class.forName("com.mysql.jdbc.Driver");
    Connection con = DriverManager.getConnection("jdbc:mysql://<<host_is_here>>/<<db_name>>?user=<<username>>");

    Hvae program to test the ODBC or JDBC Bridge and driver, so that you know you've set it up right. I gave up on applets ages ago for this sort of thing, though I do know you have to install a seperate driver for applets, perhaps someone could come in on this and guide you more
    This will teat your driver and set-up, so compile and run this code;-
    import java.sql.*;
    import java.util.*;
    public class MyConnection
         Connection con;
         MyConnection()
              try
    // ******************************Connected To Jdbc-Odbc Type - 1 Driver
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    //               con = DriverManager.getConnection("Jdbc:Odbc:dsnname","userid","password");
                   con = DriverManager.getConnection("jdbc:odbc:Driver={SQL Server};Server=servername;Database=pubs","userid","password");
    // ******************************Connected To Ms-Access JDBC ODBC Driver .
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con = DriverManager.getConnection("Jdbc:Odbc:dsnname","","");
    //               con = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=G:/admin.mdb","","");
    // ******************************Connected To Ms-Access Type-3 Driver.
         /*          Class.forName ("acs.jdbc.Driver");
                   String url = "jdbc:atinav:servername:5000:C:\\admin.mdb";
                   String username="Admin";
                   String password="";
                   Connection con = DriverManager.getConnection(url,username,password);
    // ******************************Connected To Microsoft SQL.
                   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                   con = DriverManager.getConnection("jdbc:microsoft:sqlserver://servername:1433","userid","password");
    // ******************************Connected To Merant.
                   Class.forName("com.merant.datadirect.jdbc.sqlserver.SQLServerDriver");
                   con = DriverManager.getConnection("jdbc:merant:sqlserver://servername:1433;User=userid;Password=password");
    // ******************************Connected To Atinav SqlServer.
                   Class.forName ("net.avenir.jdbc2.Driver");
                   con= DriverManager.getConnection("jdbc: AvenirDriver://servername:1433/pubs","userid","password");
    // ******************************Connected To J-Turbo.
    /*               String server="servername";
                   String database="pubs";
                   String user="userid";
                   String password="password";
                   Class.forName("com.ashna.jturbo.driver.Driver");
                   con= DriverManager.getConnection("jdbc:JTurbo://"+server+"/"+database,user,password);
    /*// ******************************Connected To jk Jdbc Driver.
                   String url= "jdbc:jk:server@pubs:1433";
                   Properties prop = new Properties();
                   prop.put("user","userid");//Set the user name
                   prop.put("password","password");//Set the password
                   Class.forName ("com.jk.jdbc.Driver").newInstance();
                   con = DriverManager.getConnection (url, prop);*/
    // ******************************Connected To jNetDirect Type - 4 Driver
    /*               String sConnect = "jdbc:JSQLConnect://127.0.0.1/database=pubs&user=userid&password=password";
                   Class.forName ("com.jnetdirect.jsql.JSQLDriver").newInstance();     
                   Connection con= DriverManager.getConnection(sConnect);
    // ******************************Connected To AvenirDriver Type - 4 Driver
    //               String url= "jdbc: AvenirDriver: //servername:1433/pubs";
    //               java.util.Properties prop = new java.util.Properties ();
    //               prop.put("user","userid");
    //               prop.put("password","password");
    /*               Class.forName ("net.avenir.jdbc2.Driver");     
                   System.out.println(" Connected To AvenirDriver Type - 4 Driver");
                   con= DriverManager.getConnection("jdbc: AvenirDriver://servername:1433/pubs","userid","password");
    // ******************************Connected To iNet Sprinta2000 Type - 4 Driver
         /*          String url="jdbc:inetdae7:servername:1433";
                   String login="userid";
                   String password="password";
                   Class.forName("com.inet.tds.TdsDriver");
                   System.out.println(" Connected To iNet Sprinta2000 Type - 4 Driver");
                   con=DriverManager.getConnection(url,login,password);
    // ******************************Connected To iNet Opta2000 Type - 4 Driver
    /*               String url="jdbc:inetdae7:servername:1433";
                   String login="sagar";
                   String password="sagar";
                   Class.forName("com.inet.tds.TdsDriver").newInstance();
                   System.out.println(" Connected To iNet Opta2000 Type - 4 Driver");
                   con=DriverManager.getConnection(url,login,password);
                   DatabaseMetaData md = con.getMetaData();
                   System.out.println("Driver Name            " + md.getDriverName());
                   System.out.println("Driver Version         " + md.getDriverVersion());
                   System.out.println("Database URL is        " + md.getURL());
                   System.out.println("Database UserName is   " + md.getUserName());
                   System.out.println("Connection Name        " + md.getConnection());
                   System.out.println("Database Name          " + md.getDatabaseProductName());
                   System.out.println("Database Version       " + md.getDatabaseProductVersion());
                   System.out.println("Database ReadOnly Type " + md.isReadOnly());
                   System.out.println("MaxColumnNameLength    " + md.getMaxColumnNameLength());
                   System.out.println("MaxConnections         " + md.getMaxConnections());
                   System.out.println("");
              catch(ClassNotFoundException cnfe)
                   System.out.println(cnfe.getException());
                   System.out.println("The Specified Driver Does not Exist....");
              catch(SQLException sqle)
                   if(sqle.getErrorCode() == 0)
                        System.out.println("No Suitable Driver Found..");
                   else if(sqle.getErrorCode() == 1017)
                        System.out.println("Wrong UserName Or Password..");
                   else if(sqle.getErrorCode() == 1034)
                        System.out.println("Database not Started..");
                        System.out.println(sqle.getErrorCode());
                        System.out.println(sqle.getSQLState());
                        System.out.println(sqle);
         public static void main (String args[])
              new MyConnection();
    }

  • Basic JDBC transactional question

    Hello all,
    I have (what I believe) is a basic transactional JDBC question.
    Here's what I want to do:
    begin transaction
    select a row from a table where (some condition).
    that row may or may not exist.
    if the row exists: update the row
    else if the row does not exist, insert a new row
    end transaction
    I want this entire thing to be atomic .. I don't want the select to complete, then have something else come in there before the update/insert takes place.
    I'm using MySQL .. I seem to remember hearing about some proprietary MySQL command which would do a SELECT + UPDATE atomically .. which would be fine, but I can't find it.
    Wrapping this with a row-level lock would be fine too .. I'm just not sure how to do that in JDBC.
    Thanks!
    -d

    By thte way, and not that it helps the orignal poster, who's using MySQL, but Oracle has a proprietary MERGE statement that does "insert or update" in one go. For example:
    MERGE INTO bonuses D
       USING (SELECT employee_id, salary, department_id FROM employees
       WHERE department_id = 80) S
       ON (D.employee_id = S.employee_id)
       WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01
         DELETE WHERE (S.salary > 8000)
       WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
         VALUES (S.employee_id, S.salary*0.1)
         WHERE (S.salary <= 8000);

  • Big difference between iMac and MacMini for a basic FCP usage?

    Hi all,
    the question is the one on the subject.
    The comparison is between the:
    - iMac 3.06Ghz 8GB 512vRam (the one on my signature here below)
    - MacMini 2.4Ghz 8GB 256vRam
    I would like to know if i will notice significant differencies in a basic usage of FCP: i mean a usage of FCP more like if it was FCExpress...

    Thanks Tom, this is due to hardware limitations i suppose ?
    There is some link/resource where i can read wich applications are compromised?
    thanks again

  • Basic SIP usage of SPA3102

    Hi All,
    Whilst I'm debugging, I just wanted to ask a quick few basic questions on using Asterisk and the 3102 together.
    The only port I was able to connect into the 3102 via IP was the Internet port, so my LAN is connected into that. The 3102 doesnt connect directly to the Internet in any way, so my LAN should be "the internet" from its perspective.
    All I want to make use of the 3102 for is directing some specific outbound calls from Asterisk to the PSTN via the 3102.  Maybe at some point have any inbound call direct into Asterisk, but thats for a later stage.
    I've defined a SIP account and the 3102 registers into A*k ok.
    I dont understand the dialplan syntax on the 3102 (any docs?? the user manual had nothing), so thats my starting point for investigation.  At the moment its set to the default of:
     (*xx|[3469]11|0|00|[2-9]xxxxxx|1xxx[2-9]xxxxxxS0|xxxxxxxxxxxx.) 
    When I place a call via Asterisk I get :
    -- Executing [2090@from-sip:1] Set("SIP/427-08ef25d0", "CALLERID(num)=02071833427") in new stack
        -- Executing [2090@from-sip:2] Dial("SIP/427-08ef25d0", "SIP/[email protected]") in new stack
        -- Called [email protected]
        -- SIP/192.168.3.54-08ef0758 is circuit-busy
      == Everyone is busy/congested at this time (1:0/1/0)
        -- Executing [2090@from-sip:3] Hangup("SIP/427-08ef25d0", "") in new stack
    I'm assuming this is the correct way to direct the call to the 3102.
    I'm thinking its the dialplan thats the problem, but how do I make all calls go via the PSTN ??
    Thanks,

    try to set the dial plan to
    xx. |  <9, xx. < : @GW0>
    the xx. will let you dial anything
    dialing 9 then the pstn number will go out of the ports line
    if you have the PSTN line registered as well to the asterisk, just dial that extension number and you should get a second dial tone for dialing to the pots line.

  • Instant client basic package usages needed

    Hi,
    I have installed oats in my laptop in windows xp operating system which is using the default database 10g express edition that comes along with the installation process of oats.
    Now i want to use the 11g database which is in oel5 in my desktop
    Both of the system are in a same network
    in order to connect,oats and 11g, the instant client basic package is needed and also the odbc supplement and i have downloaded both of the packages and extract them to the same directory in windows xp and the necessory changes have been made in system environment variable also
    when performing the system DSN test process it is failed and the error is occured TNS no listener
    help me pls

    I recommend that you do not install Instant Client on your laptop at all.
    Instead, use the Oracle client that is included in the 10g server.
    It is difficult to have more than one Oracle installation on one Windows machine, because Windows is not designed as a multi-user OS.
    All you have to do is change the connection string to point to the other database (the documentation of oats, whatever it is, should tell you how).
    Yours,
    Laurenz Albe

  • Regarding classes12.zip files for JDBC usage

    Hello friends,
    I need classes12.zip file for oracle 10g database, & where we need to place them....
    Regards,
    sai.

    Hello sai,
    I need classes12.zip file for oracle 10g databaseI'd recommend to download "general" JDBC drivers from the corresponding OTN page: [url http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html]. I'm not sure if you really want the "classes12.zip", as these drivers are for the outdated Java versions 1.2 and 1.3. Especially these do not (fully) support the current 11.2 XE release. If you can, choose the most recent 11.2 driver download that fits to the JDK version you actually want to use, e.g.      ojdbc6.jar for JDK 6. If you really need to old classes12.zip, you'll find the latest version of these in the [url http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-10201-088211.html]JDBC drivers for 10.2.
    where we need to place them....You need to place them in the classpath of the application that is supposed to use them. Since you didn't tell us anything about it, that's really hard to tell.
    -Udo

  • Tutorium on basic java usage

    Hi all!
    I was asked to do a simple java tutorium for some colleagues and I was wondering how to start with it.
    I thought about an order like this:
    1.) basic OOP thinking (with examples like the well-known tree- or car-example)
    2.) basic types (like int, float, double...)
    3.) control structure (like while, if...)
    4.) Layout of a class
    5.) writing a simple Hello World
    6.) writing a more complex Hello World with some own classes (maybe an output class or something like that)
    7.) some basic GUI stuff like creating an on JFrame with some buttons and a textarea, maybe a lowercase->UPPERCASE converter to provide basic knowledge about events and ActionListeneres
    The problem is, this is my first tutorium and I really don't know if this order is a practical one. Mostly it's the way I learned java, so it can't be completly wrong. I hope...
    Perhaps anyone with some experience can give me some hints?
    Thanks in advance!

    Maybe you can get some ideas from the Java TutorialThat was my second thought. :-) I'll go trough the tutorials in the next days, but actually they were not very helpfull to me, when I started with java.
    Anyway, good starting point.

  • Problems with basic keys usage

    I'm going crazy. Quite often now the following key or keys combinations I use the most often stop working:
    - using Shift to select all files between two clicked on items
    - using Command to select several individual files
    - using Command-c and Command-v for Copy and Paste operations
    They stop working as they should sometimes immediately after new boot, sometimes hours after my iMac was already working properly. The only solution so far is to restart the system - but problem accelerates and I need now to restart system twice and sometimes more than twice to get the keys working. Switching keyboard with another one doesn't help, it is definitely a Finder's issue.
    Desperately need a solution.

    Hi,
    Having the same problem here. Every once in a while, Finder stops working. Command F as well as other command keys stop functioning until a restart. Getting worse. Any fixes?
    iMac G5/20inch/1.8ghz/1.25GBram   Mac OS X (10.4.9)  

  • JDBC usage techniques for multi insert/update operations

    Hi,<br /><br />I have a scenario wherein I have the following xml format(simplified version)<br /><br /><student><br /><examHeader><br /> <examNo>EX123</examNo><br />  <examMajor>IndustrialChemistry</examMajor><br />  <studentNo>AS221</studentNo><br />  <status>submitted</status><br /></examHeader><br /><examDetails><br /> <Questionnaire><br />     <answers><br />          <answer><br />               <questionId>12</questionId><br />               <questionVersion>1</questionVersion><br />               <requestId>refnumber</requestId><br />               <response>Y</response><br />               <comment>Default</comment><br />          </answer><br />     </answers><br /></Questionnaire><br /><br /> <br />Now I need to update the header details into 1 table and the details content into multiple table for each question/answer combination.<br /><br />What would be the best way to achieve this ? interms of performance and also reusablilty wise ?<br /><br />I can think of an SQL execute component to perform this , but it would be a series of sql inserts as the tables have foreign key relationships.<br /><br />how do we extract the repeatable data and insert into database in an efficient way ?<br /><br />Any help would be greatly appreciated.

    Hi Senthil
    You have two options:
    1. Create a counter, and a loop in your orchestration. Loop through the rows in your XML, and on each iteration, perform the SQL statement you require. This can be a bit fiddly, but does work.
    2. This pattern comes up often enough to warrant us having built a component to automate it. We have a component that does this in a single step - it's called "XML2SQL". You can download it here:
    http://www.avoka.com/apps/checkcookie?qpac=y&qpac_code=avokaESComponents&location=%2Fapps% 2Fqpacdownload
    More info here:
    http://avoka.dnsalias.com/confluence/display/Public/XML+to+SQL+DSC
    Howard
    http://www.avoka.com

  • Basic jdbc program to connect to access

    hi ,
    Please some one help me to connect to access databse.

    are you using any IDE? if yes then you can usederby
    if not then download mysql and download theconnector
    for it.The OP wanted to know how to connect to Microsoft
    Access(!?)Oh my bad. I got four words for you OP. Stay the hell
    away from MSAccess. Try to download mysql4.1 or any
    other Sql GUI program. Access is not worth.Many of us do development for customers that have specifications that despite our own personal wants/likes have requirements of things such as DBMS. While for personal projects the developer has ultimate power most production development has the benefit/curse (however you look at it) of things such as corporate standard software and prefered services. Regardless the post starter wanted help with Access not mysql or derby.

  • Maybe it's just basic iTunes usage i'm missing...

    But when I have purchased a single song, and then later want to buy the entire album, is there a smart way to do that ?
    The way I do it today, is: iTunes Store -> Search Artists -> Click Album and Buy.
    I'm thinking of a way like: Search song, Rightclick song -> Show Entire Album.
    Jakob

    Chris CA wrote:
    Note that with *Complete My Album*, you complete every album for every song you have purchased.
    You cannot select only one album to complete.
    Umnn... My "Complete My Albums" page not only list separate albums but list separate days when the offer expires and separate prices for each album which can be selected one at a time.
    Is it possible you're considering the iTune + option which does work in batches of songs (at least it always seems to) ?

Maybe you are looking for