File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Plz give the solution for this code...... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Plz give the solution for this code......" Watch "Plz give the solution for this code......" New topic
Author

Plz give the solution for this code......

Nitin Jawarkar
Ranch Hand

Joined: Dec 18, 2004
Posts: 79
Hi,

This is my database connection code but i want to connect this local(on local terminal)code to web server, so that i can access the data(SQL Server) from my web sever.What should be the driver or any IP address of server, anybody can give me solution for this.


try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("Jdbc dbc:temp");
stmt = con.createStatement();
}
catch(SQLException e)
{
}


Cheers<br />Nitin
Vasilis Karas
Greenhorn

Joined: Mar 16, 2004
Posts: 24
Originally posted by Nitin Jawarkar:
Hi,

This is my database connection code but i want to connect this local(on local terminal)code to web server, so that i can access the data(SQL Server) from my web sever.What should be the driver or any IP address of server, anybody can give me solution for this.


try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("Jdbc dbc:temp");
stmt = con.createStatement();
}
catch(SQLException e)
{
}


Nitin, if you are trying to talk to a SQL Server DB which running on a remote machine and you wish to use ODBC, then you will be required to create an ODBC datasource on that machine AND I don't think there is a way to have your code call a remote ODBC datasource. Your java code would have to be running on this machine as well.
You should download Microsoft's free JDBC driver for SQL Server 2000, read the documentation with regards to syntax (similar to ODBC) on creating a connection to a specific DB instance on SQL server(you will probably need an account and password to pass to the driver as well).
This is a Type IV driver which allows direct calls from the client machine to the database.
Nitin Jawarkar
Ranch Hand

Joined: Dec 18, 2004
Posts: 79
hi,
supposed if i give the IP address of that remote machine and ODBC datasource name of which where is my SQL server, ok then what happen,
but it is possible that below code can work for same problem if yes then
can u suggest me the driver name and parameter for getConnection() method


Class.forName(DRIVER);
con = DriverManager.getConnection("Jdbc dbc:temp");
stmt = con.createStatement();

Actually i m creating an application which download the data from webserver using Java application which include all these problems.
Vasilis Karas
Greenhorn

Joined: Mar 16, 2004
Posts: 24
Originally posted by Nitin Jawarkar:
hi,
supposed if i give the IP address of that remote machine and ODBC datasource name of which where is my SQL server, ok then what happen,
but it is possible that below code can work for same problem if yes then
can u suggest me the driver name and parameter for getConnection() method


Class.forName(DRIVER);
con = DriverManager.getConnection("Jdbc dbc:temp");
stmt = con.createStatement();

Actually i m creating an application which download the data from webserver using Java application which include all these problems.


Nitin, I'm probably a couple of days late. Anyhow, I wasn't thinking clearly in my previous response--of course you can create an ODBC datasource on your machine and point it to the SQL server. Assuming you have the SQL server driver installed on that machine. Do you still need a code example?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Plz give the solution for this code......