• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JDBC ODBC host string

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
}
}
}
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
I will suppress my every urge. But not this shameless plug:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic