This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes JDBC ODBC host string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC ODBC host string" Watch "JDBC ODBC host string" New topic
Author

JDBC ODBC host string

dhirajsrivastava
Greenhorn

Joined: May 12, 2001
Posts: 9
hello all
i have oracle 8 installed in my system which i want to connect with my JDK1.3
here i passing the following string in DriverManager.getConnection
"jdbc dbc:thin:@(here i have to pass host string what is this?):1521 rcl8"
can any one tell me what is this host string whether it is machine name or some thing else
here is the following code:
import java.sql.*;
import oracle.jdbc.driver.*;
class tryjdbc {
public static void main(String args[]) thorws Exception {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc racle:thin:@(host string?):1521 rcl";
Connection con=DriverManager.getConnection(url,"scott","tiger");
Statement stmt=con.createStatement();
stmt.executeUpdate("CREATE TABLE BOOKS"+"(BOOK_NAME VARCHAR(32), SUP_ID INTEGER,PRICE FLOAT," +"SALES INTEGER,TOTAL INTEGER)");
stmt.executeUpdate("INSERT INTO BOOKS"+"VALUES('JAVA',101,450.00,0,0)");
}
catch(Exception e) {
System.out.println(e);
}
}
}
Smita Tyagi
Greenhorn

Joined: May 09, 2001
Posts: 21
Hello Dhiraj,
You must put a database name after the @ sign in the connection URL.You can use either the fully specified SQL*net syntax or a short cut syntax as <host>:<port>:<sid>.
Smita
dhirajsrivastava
Greenhorn

Joined: May 12, 2001
Posts: 9
hello smita
can u please tell me what is the concept of host string may i write localhost as host string and one thing more for connection b/w java and ms-accsess this driver is valid.
Thanks
dhiraj
Ambrose Tati
Ranch Hand

Joined: Oct 03, 2000
Posts: 55
I use the following:
String URL = "jdbc racle:thin:@host:1521:SID";
host: is what your machine is known as
SID: is the SID of the Oracle you want to connect to
Note that 1521 is the default Port number.
If your system has been set up so that Oracle lisnens for connections on a specific port number change it to that port number, otherwise stick to the default one.
Hope it works
Cheers
Ambrose Tati

Originally posted by dhirajsrivastava:
hello smita
can u please tell me what is the concept of host string may i write localhost as host string and one thing more for connection b/w java and ms-accsess this driver is valid.
Thanks
dhiraj


[This message has been edited by Ambrose Tati (edited May 14, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC ODBC host string
 
Similar Threads
ClassNotFoundException generated!
how to get started with jdbc
Loading Oracle JDBC Driver
jdbc in Unix
DSN less connection