Microsoftov JDBC drajver koji može (besplatno) da se skine sa MSDN-a provereno radi, a čini mi se da dolazi i sa primerom.
Evo ti primera koji ja imam, mislim da je to baš taj - možda malčice promenjen (ne sećam se više), ali PROVERENO radi.
Code:
/**
* Microsoft SQL Server JDBC test program
******************************************/
import java.sql.*;
....
....
// In this example we will connect to the 'Northwind' database in SQL server instance 'instance1' on
// machine 'server1'.
//
// If you are using the default instance then use this line (just remove instance information from the string):
// Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://server1\\instance1:1433;databaseName=Northwind","sa","sa_password");
//
// We are also using username='sa' with password 'sa_password'
try
{
DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://server1\\instance1:1433;databaseName=Northwind","sa","sa_password");
if (connection != null)
{
System.out.println();
System.out.println("Successfully connected");
System.out.println();
// Meta data
DatabaseMetaData meta = connection.getMetaData();
System.out.println("\nDriver Information");
System.out.println("Driver Name: " + meta.getDriverName());
System.out.println("Driver Version: " + meta.getDriverVersion());
System.out.println("\nDatabase Information ");
System.out.println("Database Name: " + meta.getDatabaseProductName());
System.out.println("Database Version: "+ meta.getDatabaseProductVersion());
Statement st = connection.createStatement();
ResultSet rs = st.executeQuery("SELECT TOP 100 CustomerID, CompanyName FROM Customers");
while ( rs.next() )
{
String customerID = rs.getString("CustomerID");
String companyName = rs.getString("CompanyName");
System.out.println(customerID + "\t" + companyName);
}
st.close();
connection.close();
}
}
catch ( SQLException ex )
{
System.out.println("Error: " + ex);
}
Commercial-Free !!!