Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • 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
Marshal
Pie
Posts: 24208
35
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic