Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DSN less connection

 
Madhu Mohanan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Iam new to the forum.
can anybody please tell me how make a DSNless connection to the database as they do so in ASP...
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to give us a bit more information. What sort of database do you want to connect to? Is the database running on the same machine as the java which is trying to open the connection? Do you have database drivers available for the database?
 
shams sh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
U can try Thin drivers to bypass the DSN connectiona nd make a direct connection to any database. U can use Class111.zip or classes12.zip thin drivers.
 
Madhu Mohanan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for not giving much details...well here goes....
i have to connect to both SQL as well as oracle database
i have got thin drivers apart from the general ones.
and the databases are on other machines in the network
i'd like some detailed explanations with possible code snippets...please thank you
 
Vimal Gandhi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can use Type 4 driver for DSNLess Connection.
Try on it
bye
VIMAL
------------------
 
shams sh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try the following code :
import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.*;
class oct
{
public static void main(String arg[])
{
try
{
Driver DriverresDept = (Driver)
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
Connection ConnresDept = DriverManager.getConnection ("jdbc racle:thin:@general:1521:ORCL1","scott","tiger");

PreparedStatement StatementresDept = ConnresDept.prepareCall("SELECT * FROM dept ");
ResultSet resDept = StatementresDept.executeQuery();
while(resDept.next())
{
System.out.println (resDept.getString("deptno") + " : " + resDept.getString("dname")
+ " : " + resDept.getString("loc"));
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
==========
pay attention to the following line :
DriverManager.getConnection ("jdbc racle:thin:@general:1521:ORCL1","scott","tiger");
here @general is the name of your computer/server
1521 is the port number ND
orcl1 IS THE ORACLE SID

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic