Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC ODBC host string

 
dhirajsrivastava
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic