Rabu, 25 Januari 2012

OraConnection

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uas;

import java.sql.Connection;
import java.sql.SQLException;
import oracle.jdbc.pool.OracleDataSource;

/**
 *
 * @author
 */
public class OraConnection {

    public static Connection open(String url, String userId, String password) {
        Connection conn = null;
        try {
            OracleDataSource ds;
            ds = new OracleDataSource();
            ds.setURL(url);
            conn = ds.getConnection(userId, password);
            System.out.println("Koneksi is OK");
        } catch (SQLException e) {
            // perform error handling here
            System.out.println("error :" + e.getMessage());
        }

        return conn;
    }
}

Tidak ada komentar:

Posting Komentar