Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- class TestConnection
- {
- public static void main (String[] args)
- {
- try
- {
- // Step 1: Load the JDBC ODBC driver
- Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
- // Step 2: Establish the connection to the database
- String url = "jdbc:sqlserver://10.1.73.180\SQL2000;" +
- "databaseName=reportgen;user=sa;password=*****;";
- Connection conn = DriverManager.getConnection(url);
- System.out.println("Connected.");
- }
- catch (Exception e)
- {
- System.err.println("Got an exception! ");
- System.err.println(e.getMessage());
- }
- }
- }
- Got an exception!
- com.microsoft.sqlserver.jdbc.SQLServerDriver
- Process exited with exit code 0.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement