Basics in JDBC

I'm just started to learn how to use javato connect to the database ( it's oracle ).
The tutorial gives me the direction to establish connection, so i'm using these code to load a driver and making connection:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection(
"jdbc:oracle:thin:@oracle.cslab.uky.edu:1521:csl ", username, password );
but java gives me an SQLexception " no suitable driver".
I'm current using JDK 1.4, does it already have a JDBC-ODBC Bridge driver set up ?
Do I need to do anything else to set up my computer for the connection to database ?
Please help !

but java gives me an SQLexception " no suitable driver". You are loading the jdbc-odbc bridge driver. But your connection string is set up to use the Oracle thin driver. One or the other is incorrect.
I'm current using JDK 1.4, does it already have a JDBC-ODBC Bridge driver set up ?Presumably you aren't doing production work on a beta product. 1.4 comes with the jdbc-odbc bridge driver (at least for sun and windows), but 'set up' can be a different issue and and nothing to do with java.
Do I need to do anything else to set up my computer for the connection to database ?Could be many things. For example to use a DSN connection via ODBC to Oracle you need a ODBC Oracle driver (nothing to do with java) and you need to create a DSN.
And using ODBC, or thin, or oci, you need to have access to the Oracle database from your client. This might include but is not limited to: Oracle up and running, Oracle listeners up and running, a Oracle SID create with a user and password that you know, firewalls that allow access and perhaps other things. The best way to verify all of this is to run sqlplus on your client first. If you can't connect with sqlplus then there is not point in trying with java.

Similar Messages

  • 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);

  • Scripted JDBC: no password visible

    Hi;
    I have a basic scripted JDBC connector working to an Oracle database, but no password is coming across when I create users. Sending the password is the primary reason for implementing this adapter. Can anyone shed any light on this? I have specified password as a field in the resource schema.
    thanks!
    -Bill

    I have fixed this, but I'm not too sure what was broken.
    I took the above advice and renamed my fields in my resource. At first, that didn't seem to fix it. Then, I implemented an "update" beanshell and the create started working properly. Go figure...
    I'll leave this as "unanswered" for a bit in case somebody can shed some light on this.
    -Bill

  • About JDBC

    Hi, I am a fresher studying about JDBC. I wanted to know about the basics of JDBC. i wanted to know for what purpose JDBC is used..

    hi
    there r diffrent types of jdbc connection.hope u kmow jdbc is use to connect to database.if u need jdbc -mysql connection
    1.download a mysql connector from apache site
    2.edit .bash profile and add patf of connector to classpath
    3.follow this link http://www.kitebird.com/articles/jdbc.html#TOC_1

  • Machine A will hang if Machine B is powered off.

    I use Solaris 8. If some applications (for example, telnet) on machine A attempt to connect to the the machine B, which is powered off, or removed from the network, the telnet on machine A will just hang for a long time (many minutes). Eventually, some exeptions will occur. But I believe there are some parameters at the OS level which could make the hang time shorter, say 3 seconds. Do you know what parameters could serve that purpose?
    This problem can also be observed when a JDBC application is used. Basically the JDBC (client) simply relies on the OS signal when the database (server) is powered off.
    Thanks.

    I have a T410s with 2 external monitors that I always used. 1x24inch LCD connected using VGA to VGA and 1x26inch LCD connected using displayport to HDMI. It used to be fine until some intel grapics driver update a while back.
    So I come to believe is the driver fault and/or the internal graphic card lack of capacity.
    My solution is to setup the monitors the way I like is to change the BIOS to boot up from displayport, and when successful going into the desktop then disable the laptop LCD. Then connect the 2nd LCD, extend the desktop and setup the resolution. From that point on I must always boot up with VGA disconnect then after into desktop, plug in the VGA cable and it will show up fine. If I forget and left the displayport + VGA connected when I bootup, it will fail and I have to do the initial setup again.
    So something with the displayport/graphic card/graphic memory is making the T410s 'forget' or discard the displayport. or the 1900x1200 resolutions of 2x monitors overwhelm the graphics card memory and it had to made a choice or give up. Most of the time it just goes blank or flash on/off
    In your case, if you only have 1x external monitor you can just change the BIOS to bootup screen in VGA/Displayport/Dock and when in the dsektop, set to duplicate mode for both screens. Then download this utility called ultramon and use it to setup the extended display setting to your liking, save the profile on the desktop/startup folder. When your T410s bootup, intel driver will boot in duplicate mode so it will go into the desktop, once it's there, the ultramon will takes over and change it to the extended setup. Play with the sequence/settings a bit to see which ones works for your setup....and hope lenovo comes up with better drivers.

  • Help!! How To Connect Java & PostgreSQL Database

    I'm final year student in comp sc. I'm doing java in my thesis.
    How to get/read data from postgresql using java?
    My thesis is "2 Dimensional Graph Statistics Online Viewing Using Java Applet". So i need a mechanism how to read data from postgresql database using java programming. Please Help!!

    Hi,
    getting started you need some basics on JDBC.
    Have a look at the tutorials, or look at this site (its german):
    http://www.furchur.de/de/informatik/laborberichte2.htm#dbswt
    Have a look at the java.sql package.
    First you need to build up a connection using
    java.sql.DriverManager.getConnection(...)
    The parameter for the PostgreSQL you must look somewhere.
    After you have a connection you can use Statements and PreparedStatements to get and set data in the database.
    At the end, make sure, the connection will be closed, otherwise data can be lost.
    Hope that will help you a little bit

  • Installing Stored Procedure on a remote DB

    Hi,
    Is it possible to install stored procedures from a
    JDBC client without using tools like sqlplus?
    Thanks and regards,
    Venkat.

    Hi
    Basically via JDBC you can execute all SQL statements. Therefore it is not a problem. Just write your own tool or do a search on the internet... we will certainly find one!
    Chris

  • Error connecting to MySQL database

    Well I am a beginner trying to get the basics of JDBC. I am following a simple connection tutorial and I cannot even make this work. I receive an error when I run the program. It is a nested error that begins with "java.io.EOFException". I'm thinking it has something to do with the URL I am using to connect to the database. Any ideas?
    Here is the code I am using if that helps at all.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class jdbctry {
      public static void main(String args[]) {
        Connection con = null;
        try {
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          con = DriverManager.getConnection("jdbc:mysql://url:port/database",
          if(!con.isClosed())
            System.out.println("Successfully connected to " +
              "MySQL server using TCP/IP...");
        } catch(Exception e) {
          System.err.println("Exception: " + e.getMessage());
        } finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
    } edit- I think the problem was I had a bad port number assigned to the URL. This time I got a "java.net.SocketException" error. It says my connection timed out.
    Message was edited by:
    lw22

    I'll assume that you've substituted appropriate values into that connection URL, right?
    It s
    // host = IP address or name of machine where MySQL is listening
    // port = 3306 (default)
    // database = instance you wish to connect to
    // username, password have to be GRANTed access rights.
    String url = "jdbc:mysql://host:port/database";Can you connect using the MySQL client and see the database you want in Java? If the client can't connect, neither can JDBC.
    %

  • How to connect servlet to mysql database

    Hi all,
    I am new to mysql. After many difficulty I have created a database with table in MySql. Now I want to connct it to a servlet. How do I do it?
    Can anyone tell me the steps, including the step to create MySql datasource
    thanks

    thanks for the reply. I know the basics of jdbc and can connect with sqlserver. Bt how to connect with Mysql? I mean what do I provide in dsn unless I create a MySql datasource. I cant find any tutorial which teaches how to create MySql datasource. Can you give me any link???
    thanks

  • CCA agent (oc4jadmin) for template mappings - local or on server?

    I am unclear which one should be used or which one is better to use? Perhaps it doesn't matter....
    Also, if the choice is server, should it be on the server where the design repositories are or on the runtime platform?
    Edited by: user12019055 on Nov 30, 2010 11:38 AM

    Hi Julian
    So out of the box with code template mappings, OWB would use the SQL to Oracle LKM to move the data and this is basically the JDBC style data movement. You should make sure you have the latest JDBC drivers from Microsoft, and a URL to connect which will scale for the volume of data you are moving.
    You should be aware of a parameter selectMethod in the SQLServer connection URL, if moving larger amounts of data (depending on platform/versions) you may need to enable server side cursors which is done using this parameter, so the connection URL would be something like;
    jdbc:sqlserver://yourhost:yourport;databaseName=yourdatabase;selectMethod=cursor;
    Also if you are running the CCA on Linux 11.2.0.1, I think you will need to change the heap size of the CCA, change it to 512M which will make it the same default as Windows and current patched OWB. In the ccastart file under unix you can change -mx128M values to -mx512M
    Cheers
    David

  • Installing oracle instant client 12.1 on Windows 8 with no previous Oracle Software

    Hi all,
    I want to install oracle client 12.1 on my 64bit windows 8 computer. Do i have to have an oracle software installed first?
    I've downloaded all the packages from the oracle website ie, basic, odbc, jdbc, sqlplus and sdk
    I have extracted them into one folder c:\Program Files\OracleInstantClient. as told to do in the documentation
    These are the actions I have taken as suggested by different forums which i have done;
    - created a system variable OCI_LIB64 and set the value to c:\Program Files\OracleInstantClient.
    - created a system and user variable ORACLE_HOME and set the value to c:\Program Files\OracleInstantClient.
    - created a user variable TNS_ADMIN and set the value to c:\Program Files\OracleInstantClient.
    - create subfolders "\network\admin" in your 64-bit client folder and create sqlnet.ora and tnsnames.ora here ie c:\Program Files\OracleInstantClient\network\admin
    In another installation guide i found, i was told to double click a setup.exe and start the GUI which i didn't see after i extracted all the downloads
    Please am missing something? do i have to install oracle database first? i really don't need that.

    You do not have to install oracle database in order to install oracle client.  But it won't do any good to install the client if you don't have a database to connect to -- somewhere.  It's just that the database doesn't have to be in the same box as the client.  In fact, it usually isn't.
    You created a directory "c:\Program Files\OracleInstantClient\network\admin" to hold your tnsnames.ora and sqlnet.ora files. But then you set tns_admin to point to some other directory.  If you set tns_admin, you are telling the client THAT is where it should locate the tns config files.
    Oracle sometimes doesn't like putting things in Windows folders that have embedded spaces in the folder name.  I'd avoid it like the plague.

  • Record Locks

    Hello all,
    Now this might sound like a very beginners question but here goes.
    I have been programming in Java for over 2 years so I understand the basics of JDBC. Now I just started a job and am trying to develop an application for the client. First of all what is a record locking? I am using Oracle 9i as a database. This application will be placed on a server in a directory where clients will access it. What I want is once a user is modifying a record on a MODIFYDIALOG others should not be able to read/add/modify it. Somehow this is not working correctly. Database object property to use transactions is set to true and the level i am using is "SERIALIZABLE". But I am unable to achieve my goal of record locking. I was able to solve all the other problems that i came across by visiting the previous posts but this one is really out of hand here.
    I know this is a very childish question but I will be really thankful if someone can explain it to me and tell me what and how to do it.
    Regards

    Did you look at these?
    http://onesearch.sun.com/search/developers/index.jsp?col=devforums&qp_name=Java+Database+Connectivity+%28JDBC%29+%26+Transactions+%28JTA%2FJTS%29&qp=forum%3A48&qt=%2Boracle+%2B%22record+locking%22

  • 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();
    }

  • Difference in Edit functionality between JDBC & Basic/TNS connections

    Hi, I just noticed that there's a difference in functionality in whether the edit table option is available or not depending on whether you connect using a JDBC connection or Basic/TNS.
    Version 2.1.1.64 Build MAIN-64.45
    I have checked the server and port are identical in all 3 types of connection. I have tried this using both with the JDK and NON-JDK versions and same problem occurs.
    It's a bit hit and miss and not all users in all databases are affected.
    I can replicate the problem simply.
    I connect to the user/database using a JDBC connection.
    I create a table
    create table mytest as select * from dual;
    I right-click the table and the option to edit it is missing.
    I then right-click the table and select table-drop
    I then connect to the same database as the same user using either a Basic or TNS connection.
    I can now right clcik the table and select Edit and add indexes etc.
    As I usually use JDBC connections this is quite a pain. The problem seems to affect all objects not just tables.
    As I was typing this I found the work-around in that if you select the object and then choose Edit->Properties from the main menu then the functionality works.
    Thanks
    Arth

    RJ
    Generally speaking no there shouldn't be much difference, it is more a question of functionality.
    In fact with IP Services there may be more load in terms of CPU and memory usage if you are running features you can't run on IP Base but in terms of hardware forwarding, as far as I am aware, the feature set should not make any difference.
    Edit - the choice of which image to use really comes down to which features you want to run on your switches rather than a performance one.
    Jon

  • JDBC Basics

    DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
    My question is based upon this code frag. It seems to be registering the driver to be used in a connection later. My question is where is the driver that it is registering? Is it part of some class or is it to be found in the oracle home on my PC?
    I'm new to this db game hence the probably very basic question, any help would be brilliant as books are one thing but experience is quite another.
    Cheers

    Hi,
    How exactly would you do this? I've pasted ojdbc14.jar into Java\jre1.6.0_07\lib\ and then tried to run the following command in command prompt:
    java -cp .;"C:\Program Files\Java\jre1.6.0_07\lib\ojdbc14.jar" OracleLoadDriver
    Edit: nevermind. For those having the same problem know that "adding to the class path" does not mean the CLASSPATH variable but (in Netbeans) Run / Set Project Config / then add the .jar.
    Mike
    Edited by: Dird on May 20, 2010 10:47 AM

Maybe you are looking for

  • Safari copy url button doesn't work

    I just upgraded from an ipad2 to an iPad air 2. Before, if I wanted to copy and paste a url I'd use the copy button. Now,on the new iPad air 2, the copy button just wipes out whatever I've previously copied, and doesn't copy the url.

  • Lr Mobile 1.2.1 does not recognize .tif files added to iPhone 6 + iOS8 Camera Roll

    I use an app called ProCamera 8 to save images taken with my iPhone 6 to uncompressed TIF files or TIF files with LZW compression.  The problem is that Lr Mobile doesn't see any kind of TIF file in my iPhone camera roll at all.  I've tried to: Save t

  • Physical and Books stocks report

    Hi Experts, I want to show the  report  with stock  key figures as Physical and Book stock quantity and values in Bex report. Plz let me know any BW  standard cube or ODS  available for this. Thanks in Advance, chandra

  • Where are Messages 8.0 notifications?

    My wife came home from work and said "Did you get my text?"  I said, "no I did not".  I checked the Messages.app on my iMac where I had been working, and there was no notification I could see except for a tiny red "1" on the Messages icon on the dock

  • Cannot connect at a site, whereas other iPad users can? What happened?

    I fail to find a network at a particular site while other iPad users have no problem connecting? I have not encountered this before? Is this something to do with the 'forget this network' button, which I may have pressed trying to connect? Help pleas