Connecting to an Oracle Database
This example uses an Oracle JDBC driver to connect to an Oracle
database instance located at 128.0.0.0:1521 with an sid called
mydatabase.
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
// Create a connection to the database
String serverName = "127.0.0.1";
String portNumber = "1521";
String sid = "mydatabase";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "username";
String password = "password";
connection = DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
// Could not find the database driver
} catch (SQLException e) {
// Could not connect to the database
}
I set
catch (ClassNotFoundException e) {
return ("Could not find the database driver");
}
and I get
Method returned
java.lang.String : "Could not find the database driver"
I must copy to a directory ojdbc14.jar, where must be that?
Thanks
Great Work. helped me for sure.
please tell me about odbc connection with java
Perdón por el español, pero muchas gracias me sirvió mucho su ejemplo.
Good work!
Nice..............
that is work
Cheapest Name Brand New backpack designer Handbags bags fashion clothing wholesale from China www.besoso.com
www.brandsalechina.com
good! it's work well...