|
|
Hi frns,
I am stuck with a problem.I could'nt connect to oracle.
I am using oracle8i fully installed.
I have included classes12.rar file to classpath.
do I need to install any drivers. or need to set any other path
plz let me know
feel free to contact me at vsphanindra@yahoo.com
"the error I am getting is "
package oracle.jdbc does not exist
Class.forName(new oracle.jdbc.OracleDriver());
and the code I used to connect to database is
// import Oracle.*;
import java.sql.*;
//import package oracle.jdbc ;
public class Data {
public static void main(String[] args) {
Class.forName(new oracle.jdbc.OracleDriver());
//Connection con =
//DriverManager.getConnection"jdbc:oracle:thin:@hostname:1526:orcl","scott","ti ger");
}
}
thnx in advance
phanindra.
|
|
|
|
|
|
|
|
jdbc:oracle:thin:[<user>/<password>]@//<host>[:<port>]/<service>
Example below connects to Oracle Database instance using JDBC-Thin Type 4 Driver.
import java.sql.*;
public class getOracleConnection
{
public static void main(String[] args)
{
DB db = new DB();
Connection conn=db.dbConnect(
"jdbc:oracle:thin:@localhost:1521/test", "scott", "tiger");
}
}
class DB
{
public DB() {}
public Connection dbConnect(String db_connect_string,
String db_userid, String db_password)
{
try
{
DriverManager.registerDriver(
new oracle.jdbc.OracleDriver());
Connection conn = DriverManager.getConnection(
db_connect_string, db_userid, db_password);
System.out.println("connected");
return conn;
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
};
-----------------------------------------
So this datya can help you .................
|
|
|
|
|
|
|
|