The Artima Developer Community
Sponsored Link

Java Answers Forum
JDBC Oracle8i connectivity problem

1 reply on 1 page. Most recent reply: Oct 10, 2002 10:03 AM by Don Hill

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Neeraj

Posts: 1
Nickname: tinku
Registered: Oct, 2002

JDBC Oracle8i connectivity problem Posted: Oct 9, 2002 3:19 PM
Reply to this message Reply
Advertisement
I have jdk 1.2.2 & oracle8i Enterprise server edition, windows2000 Advanced server. I have tried to access the database through JDBC but unable to connect to the database. I have written the code this way.

import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import oracle.jdbc.driver.OracleDriver;

public class Employee
{
public static void main(String[] args)
{
String empName="Neeraj Kumar Singh";
String userName="scott";
String passWord="tiger";
Connection conn=null;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
System.out.println("Connecting to database...Wait...");
conn=DriverManager.getConnection("jdbc:oracle:oci8:@neeraj","scott","tiger");
System.out.println("The connection is succeeded... ");
}
catch(SQLException e)
{
System.out.println("SQL State..." + e.getSQLState());
System.out.println("SQL ErrorCode..." + e.getErrorCode());
System.out.println("SQL ErrorCode..." + e.getMessage());
System.out.println("The connection is failed...");
}
catch(ClassNotFoundException e)
{
System.out.println("Class Not Found Exception exception occured...");
}
}
}

It is not actually connecting neither giving error. What is the solution and possible cause?


Don Hill

Posts: 70
Nickname: ssswdon
Registered: Jul, 2002

Re: JDBC Oracle8i connectivity problem Posted: Oct 10, 2002 10:03 AM
Reply to this message Reply
try placing a
catch(Exception _e ){
_e.printStackTrace()
}
at the end maybe theres a exception or null pointer and your not catching it.


HTH
Don
> I have jdk 1.2.2 & oracle8i Enterprise server
> edition, windows2000 Advanced server. I have tried to
> access the database through JDBC but unable to
> connect to the database. I have written the code this
> way.
>
> import java.io.*;
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.SQLException;
> import oracle.jdbc.driver.OracleDriver;
>
> public class Employee
> {
> public static void main(String[] args)
> {
> String empName="Neeraj Kumar Singh";
> String userName="scott";
> String passWord="tiger";
> Connection conn=null;
> try
> {
> Class.forName("oracle.jdbc.driver.OracleDriver");
> DriverManager.registerDriver(new
> ew oracle.jdbc.driver.OracleDriver());
> System.out.println("Connecting to
> to database...Wait...");
> conn=DriverManager.getConnection("jdbc:oracle:oci8:
> neeraj","scott","tiger");
> System.out.println("The connection is succeeded...
> .. ");
> }
> catch(SQLException e)
> {
> System.out.println("SQL State..." +
> + e.getSQLState());
> System.out.println("SQL ErrorCode..." +
> + e.getErrorCode());
> System.out.println("SQL ErrorCode..." +
> + e.getMessage());
> System.out.println("The connection is
> is failed...");
> }
> catch(ClassNotFoundException e)
> {
> System.out.println("Class Not Found Exception
> on exception occured...");
> }
> }
> }
>
> It is not actually connecting neither giving error.
> What is the solution and possible cause?

Flat View: This topic has 1 reply on 1 page
Topic: Timestamp format to yyyyMMdd using simple date format Previous Topic   Next Topic Topic: i include string.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use