Подключаем oracle JDBC
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package thinclient;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
/**
*
* @author brudanovom
*/
public class ThinClient {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws SQLException {
// TODO code application logic here
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.1:1521:SID","user","password");///необходимо в библиртеки проекта добавить драйвер
Statement stmt = con.createStatement();
ResultSet rset = stmt.executeQuery ("select distinct(SHORT_NAME) SHORT_NAME from table");
while (rset.next ())
System.out.println (rset.getString ("SHORT_NAME"));
rset.close();
ResultSetMetaData rsetData = rset.getMetaData();
Float d = rset.getFloat(1);
String val = d.toString();
stmt.close();
con.close();
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package thinclient;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
/**
*
* @author brudanovom
*/
public class ThinClient {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws SQLException {
// TODO code application logic here
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.1:1521:SID","user","password");///необходимо в библиртеки проекта добавить драйвер
Statement stmt = con.createStatement();
ResultSet rset = stmt.executeQuery ("select distinct(SHORT_NAME) SHORT_NAME from table");
while (rset.next ())
System.out.println (rset.getString ("SHORT_NAME"));
rset.close();
ResultSetMetaData rsetData = rset.getMetaData();
Float d = rset.getFloat(1);
String val = d.toString();
stmt.close();
con.close();
}
}
Комментариев нет:
Отправить комментарий