Exforsys

Online Training

oracle database connectivity

This is a discussion on oracle database connectivity within the Java Tutorials forums, part of the Articles and Tutorials category; Hi all can any one tell me , how to connect the database in java? Is there any need to set ...


Go Back   Exforsys > Articles and Tutorials > Java Tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-04-2005, 03:11 PM
Junior Member
 
Join Date: Feb 2005
Posts: 1
gayatri
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-04-2005, 05:11 PM
Senior Member
 
Join Date: Jun 2004
Posts: 353
kalareddy is on a distinguished road
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 =
\"jdbcracle:thin:scott/tiger@www.myCompany.com:1243:myInstance\";
// jdbcracle: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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-06-2005, 11:12 AM
Junior Member
 
Join Date: Jul 2004
Posts: 2
panickiller
Can any know SQL Server connection in java (JDBC)

I need it immediately. Please, help me.


ok bye..bye.bye.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-08-2005, 02:48 PM
Junior Member
 
Join Date: Jul 2004
Posts: 2
panickiller
MSSQL Database connectivity in JDBC?

Can any one know the MSSQL database connection in JDBC. If there is? help me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-08-2005, 04:16 PM
Senior Member
 
Join Date: Jun 2004
Posts: 353
kalareddy is on a distinguished road
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
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 12-27-2005, 07:52 AM
Junior Member
 
Join Date: Dec 2005
Posts: 2
kaatamraju is on a distinguished road
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("jdbcracle:thin:@localhost:1521rcl",scott","tiger");
Sysem.out.println("connecting to Oracle Database..........");
Sysem.out.println("connected to Oracle Database");
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 12:12 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.