I'm new to JDBC. I am just trying to do a simple query on an Oracle DB.
For some reason I am getting a ClassCast Exception when I add the properties argument to the DriverManager. When I leave the properties argument out, it runs fine but can't connect to the DB because my user/password for the DB is not the same for my local computer. My code is as follows. Thanks for you help:
/* * Created on Jul 11, 2006 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package junit;
// ClassCastException here only when I add the properties argument connection = (Connection) DriverManager.getConnection(dsURL, properties);
if (connection == null){ System.out.println("Sorry, could not establish a connection"); }else{ System.out.println("Connection successfull"); Statement statement = (Statement) connection.createInputStream(); int rc = 0;
// put query in here ResultSet rset = statement.executeQuery("select * from person where xlastname = 'SMITH'");
In the long run, you will really really really really not want to use the JDBC-ODBC bridge with Oracle, but use an Oracle-native driver instead, probably the type 4 "thin" driver.