How to connect to database through java without creating dsn?

Showing Answers 1 - 12 of 12 Answers

Ranjan

  • Dec 18th, 2006
 

Hi We can connect a database using TYPE-3 thin driver without creating dsn. For more details pls visit www.sun.java.com or mail me.

  Was this answer useful?  Yes

deepak sharma

  • Dec 20th, 2006
 

Hi Ranjan,

Could you tell me more about me about type 3, with a short example..

Deepak sharma

deepak.btg@gmail.com

  Was this answer useful?  Yes

vini.rana

  • Aug 12th, 2008
 

We have four types of drivers
type1, type2, type3, type4 and we use JDBC and ODBC.
We can connect the database b/w two computers using type 3 and 4 drivers. Type 3 and 4 directly calls the native methods of the database.
If the database and Java are in same computer. Then we need type 1 and type 2 computers.

  Was this answer useful?  Yes

Ashique

  • Aug 13th, 2008
 

Steps Includes:

1. Get the URL where the database is exist, get the user name and the password.
2. Register the proper database driver.
3. Get database connection using DriverManager with the above information.
4. Once we got the connection, we can make and issued SQL Statements
to query or update the database.

Eg.
String URL = "jdbc:postgresql://XXX.XX.XX.XX:XXXX/databaseName";
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection(url,"userName","password");
Statement stmt = con.createStatement();
:
:

Regards
Ashique E.K.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions