Showing posts with label downloaded. Show all posts
Showing posts with label downloaded. Show all posts

Friday, February 24, 2012

JDBC und SQL Server

Hi,
Im very new in this topic.
And now I want to read some data from a SQL Server with Java.
But I dont know how.
I have now downloaded the new Driver form Microsoft and now I want to read
data from the SQL Server with Java.
Can someone give me a little example.
Sincerly Patrick Hennig
Hi Patrick,
Here's some sample code:
Connection connection = null;
try {
String driverName = "jdbc:microsoft:sqlserver://";
String serverName = "127.0.0.1";
String portNumber = "1433";
String myDatabaseUrl = serverName + ":" + portNumber;
String myDatabaseName = "DatabaseName=Northwind";
String url = "jdbc:microsoft:sqlserver://" + myDatabaseUrl + ";" +
myDatabaseName;
String username = "username";
String password = "password";
// Load the JDBC driver
Class.forName(driverName);
// Create a connection to the database
connection = DriverManager.getConnection(url, username, password);
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT CustomerId, CompanyName FROM
Customers");
while (rs.next()) {
System.out.println(rs.getString("CustomerId"));
System.out.println(rs.getString("CompanyName"));
}
rs.close();
} catch (ClassNotFoundException e) {
// Could not find the database driver
e.printStackTrace();
} catch (SQLException e) {
// Could not connect to the database
e.printStackTrace();
}
finally {
try {
connection.close();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
A great place to find all kinds of Java sample code is here:
http://javaalmanac.com/cgi-bin/search/find.pl?words=sql
- Tim
"Patrick Hennig" <patrick_hennig@.licht-concept.de> wrote in message
news:%23mXDLUsgEHA.3944@.tk2msftngp13.phx.gbl...
> Hi,
> Im very new in this topic.
> And now I want to read some data from a SQL Server with Java.
> But I dont know how.
> I have now downloaded the new Driver form Microsoft and now I want to read
> data from the SQL Server with Java.
> Can someone give me a little example.
> Sincerly Patrick Hennig
>

JDBC SQL 2005 download error

While i try to download jdbc for sql 2005 in english, the file that i downloaded was in italian. i've tried all version but he always download italian version. Anyone notice that?

When did you notice this behavior?

We are currently twiddling with the page trying to add the v1.1 final version to the page and we may have broken something.

|||

We republished the v1.1 product and are adding v1.0 back.

For people in non-US locales -- can you confirm that you can get the v1.1 ENU download now?

-shelby

Shelby Goerlitz

Microsoft SQL Server Data Programmability