Question subject: Connecting to SQLServer 2000 using JDBC
Posted: Sat Apr 07, 2007 2:59 pm
Joined: Tue Mar 27, 2007 10:55 pm Posts: 2279 Location: Earth Has thanked: 39 time Have thanks: 61 time
Connecting to SQLServer 2000 take from me 2 days until i discovered the problem, I tried all the solutions on the net until i installed the Service Pack 3, In fact the TCP server of SQL-Server 2000 was not working . u can check that using : Telnet localhost portnumber in the command line
But after installation of Service pack3 finally TCP server work fine and i connected to the Database Server
So the first thing to do is to check the TCP server. Second if it not working try to install Service pack3 from Microsoft
Here is the code to Open A connection to SQL-server 2000 using Microsoft JDBC
Notes : WSD is the name of the connection name you made in the ODBC. Line 4 is used if you want to execute a select statement and you can read data using string return = result.getString(ط£آ¢أ¢â€ڑآ¬ط¥â€œhere you put the columns index you want to get its valueط£آ¢أ¢â€ڑآ¬أ¢â‚¬إ’); // 1 as an example To move the pointer of reading you write result.next(); DonØ·Â£Ø¢Â¢Ø£Â¢Ã¢â‚¬Ú‘Ø¢Â¬Ø£Â¢Ã¢â‚¬â€Ø¢Â¢t forget the import statement. Line 4 is used to execute any non- select statement.
To make a connection name called ط£آ¢أ¢â€ڑآ¬ط¥â€œmydbط£آ¢أ¢â€ڑآ¬أ¢â‚¬إ’ do the followings: Control Panel -> Administrative Tools - >Data Sources (ODBC) -> add Search for SQL Server then - > choose it and then click Finish Write a name, description and name of your server - > name is ط£آ¢أ¢â€ڑآ¬ط¥â€œmydbط£آ¢أ¢â€ڑآ¬أ¢â‚¬إ’ and server is your SQL Server Name Then click next, then another next. Change the default database to ط£آ¢أ¢â€ڑآ¬ط¥â€œand choose your oneط£آ¢أ¢â€ڑآ¬أ¢â‚¬إ’, example ط£آ¢أ¢â€ڑآ¬ط¥â€œNorthWindط£آ¢أ¢â€ڑآ¬أ¢â‚¬إ’ then next and then finish. You may test Data Source , then click ok
Now, you made a Data Source than is connected to your database, for my example it is ط£آ¢أ¢â€ڑآ¬ط¥â€œNorthWindط£آ¢أ¢â€ڑآ¬أ¢â‚¬إ’ And now Line 4 and 5 must be from the tables in NorthWind ط£آ¢أ¢â€ڑآ¬ط¢آ¦ and now you may change WSD in line 2 to be mydb.
tetosoft
Question subject: Re: Connecting to SQLServer 2000 using JDBC
Posted: Mon Jun 18, 2007 5:38 pm
Joined: Wed Mar 28, 2007 1:17 pm Posts: 118 Location: Cairo-Egypt Has thanked: 0 time Have thanks: 5 time