• Post Reply Bookmark Topic Watch Topic
  • New Topic

connet to sql server and run query

 
James Ajewole
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what i want to do but i dont know how possible it is:
I want to write a program to connect to an sql server database over a lan and execute a select query and have the results returned to me and displayed in a table in the java program. Any ideas? thanks
james
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quite possible, but offtopic for this forum. Moving this post to "JDBC", the forum that deals with the Java DataBase Connectivity API, which lets you talk to databases.
 
Jason Steele
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use url connection string:
jdbc:microsoft:sqlserver://yourServerName:1433;user=yourUser;password=yourPwd
found atHOWTO: Connect to a SQL Server 2000 Named Instance with JDBC
Good Luck
 
Jason Steele
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note: Port may be different!
 
James Ajewole
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i connect to an sql server 7 server from a java program. and what do i need to configure on the server?
 
Dana Hanna
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to purchase a SQL Server 7 driver (MS does not provide one, and the 2000 driver does not work) or use the ODBC bridge driver (sun.jdbc.odbc.JdbcOdbcDriver) with URL jdbc dbc:<odbc name>. Note that with ODBC you need to make an ODBC entry on the machine for the database.
Also note that the odbc bridge driver performs very poorly, and gives unexpected results. It's not meant for production use.
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!