Wednesday, August 09, 2006

Install MS SQL Server for jdbc

- Install MSDE (MS SQL Server developer edition) server on XP
- On server open enterprise manager, right click server name and select properties. Click on the Security tab. Under Authenication, select SQL Server and Windows. That's Mixed Mode, meaning it will allow Windows Authenication mode as well as logins defined in the database.
- To define your own login to the DB, go to security in the expanding tree. Then click on Logins. Right click on the blank space in the right pane and select new Login. Type a name, and select SQL Server Authenication, then type a password. On the next tab (Server Roles), check the System Administrators box. Now click OK.
- Under general tab, network configuration needs to have correct port (default 1433)

Java code:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String sys = "jdbc:microsoft:sqlserver://192.168.0.131";
conn = DriverManager.getConnection(sys, "n", "p");
System.out.println("Connecting to: " + sys);
Statement stmt = conn.createStatement();
String sql = "SELECT fname , lname FROM pubs.dbo.employee ";
ResultSet rs = stmt.executeQuery(sql);

0 Comments:

Post a Comment

<< Home