Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Connect Class Cast Exception  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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;

import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;


public class SimpleJDBC {

public static void main(String[] args) throws Exception {

Properties properties = new Properties();

String dsURL = "jdbcdbc:EnterpriseTest";

Connection connection;

// 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");
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'");

String firstName = rset.getString("XFIRSTNAME");


Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!