tkaczanowski

jdbc connection

Jul 5th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. class JdbcTest1 {
  4.  
  5.   public static void main (String[] args) {
  6.     try
  7.     {
  8.       // Step 1: Load the JDBC driver.
  9.       Class.forName("com.mysql.jdbc.Driver");
  10.       // Step 2: Establish the connection to the database.
  11.       Connection conn = DriverManager.getConnection("jdbc:msql://www.mysql.server:3306/db_name","user1","password");  
  12.     }
  13.     catch (Exception e)
  14.     {
  15.       System.err.println("Got an exception! ");
  16.       System.err.println(e.getMessage());
  17.     }
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment