package orhan;

//import javax.swing.*;
//import java.awt.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;

public class mainClass {

static String userid = “ORHAN”, password = “PASSWORD”;
static String url = “jdbc:odbc:DB_CONN”;
static Connection con = null;

public static void main(String[] args) throws Exception {
Connection con = getOracleJDBCConnection();
if (con != null) {
System.out.println(“Connected.”);
Statement stmt = con.createStatement();
ResultSet rset = stmt.executeQuery(“select * from orhan.tablespace_size_daily”);
while (rset.next()) {
System.out.printf(“%20s %20s %15s %15s %15s %10s \n” ,rset.getString(1), rset.getString(2),rset.getString(3),rset.getString(4),rset.getString(5), rset.getString(6));
}
rset.close();
stmt.close();
con.close();

} else {
System.out.println(“Not Connection”);
}
}

public static Connection getOracleJDBCConnection() {

try {
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
} catch (java.lang.ClassNotFoundException e) {
System.err.print(“ClassNotFoundException: “);
System.err.println(e.getMessage());
}

try {
con = DriverManager.getConnection(url, userid, password);
} catch (SQLException ex) {
System.err.println(“SQLException: ” + ex.getMessage());
}

return con;
}
}

Reklamlar