
- Forum
- Programming Talk
- Java
- oracle database connectivity
oracle database connectivity
This is a discussion on oracle database connectivity within the Java forums, part of the Programming Talk category; Hi all can any one tell me , how to connect the database in java? Is there any need to ...
-
oracle database connectivity
Hi all
can any one tell me ,
how to connect the database in java?
Is there any need to set any path in the env variable for execution ?
thanx in advance,
g3.
-
02-04-2005, 05:11 PM #2kalareddy Guest
Re:oracle database connectivity
Oracle Corporation has released a free 100% JAVA driver. It is available at their Web site. According to the security rule, the Oracle server must be on the same machine as the Web server, since the communication with the Applet is done through Sockets. This is not always possible, so you will need something called a Connection Manager (from Oracle) or DBAnywhere from Symantec (demo version available for testing) to act as a bridge between the client, the Web server and the Database server.
Script sample :
import java.sql.*;
public class connectToOracle extends java.applet.Applet {
Driver driver;
Connection conn = null;
static String driverUsed =
\"oracle.jdbc.driver.OracleDriver\";
static String serverAddress =
\"jdbc
racle:thin:scott/tiger@www.myCompany.com:1243:myInstance\";
// jdbc
racle:thin is the driver used
// scott/tiger is user/password
// www.myServer.com is the same machine from where the Applet was loaded
// 1234 is the port used
// myInstance is where my data is
public void init(){
makeConnection(serverAddress);
}
public void makeConnection(String svr) {
try {
System.out.println(\"Loading ... \" + driverUsed);
driver =
(Driver)Class.forName(driverUsed).newInstance();
System.out.println(\"Connecting ... \" + svr);
conn =
DriverManager.getConnection(svr);
System.out.println(\"Ready.\"
;
}
catch (Exception e) {
e.printStackTrace();
}
}
}
Please read the tutorial below to understand how this works...
http://www.caucho.com/products/resin/ref/db-config.xtp
-
03-06-2005, 11:12 AM #3
- Join Date
- Jul 2004
- Answers
- 2
Can any know SQL Server connection in java (JDBC)
I need it immediately. Please, help me.
ok bye..bye.bye.
-
03-08-2005, 02:48 PM #4
- Join Date
- Jul 2004
- Answers
- 2
MSSQL Database connectivity in JDBC?
Can any one know the MSSQL database connection in JDBC. If there is? help me
-
03-08-2005, 04:16 PM #5kalareddy Guest
Here are few links.....
http://www.awprofessional.com/articl...&seqNum=6&rl=1
e236. Connecting to a MySQL Database
This example connects to a MySQL database using the MM JDBC driver for MySQL. You need to have an account in MySQL database to run this example. To create an account, you can connect to MySQL database on your platform as root, and run the following command:
mysql> GRANT ALL PRIVILEGES ON *.* TO username@localhost
IDENTIFIED BY 'password' WITH GRANT OPTION;
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "org.gjt.mm.mysql.Driver"; // MySQL MM JDBC driver
Class.forName(driverName);
// Create a connection to the database
String serverName = "localhost";
String mydatabase = "mydatabase";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
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
}
-
12-27-2005, 07:52 AM #6
- Join Date
- Dec 2005
- Answers
- 2
oracle data base connectvity
import java.sql.*;
class Appl
{
public static void main(String args[])throws Exception
{
Driver d=new oracle.jdbc.driver.OracleDriver();
//register to driver
DriverManager.registerDriver(d);
//connect to oracle data base
Connection c=DriverManager.getConnection("jdbc
racle:thin:@localhost:1521
rcl",scott","tiger");
Sysem.out.println("connecting to Oracle Database..........");
Sysem.out.println("connected to Oracle Database");
}
}
-
Sponsored Ads

Reply With Quote





