• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
{
}
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic