package database;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class Oracle extends javax.swing.JFrame {
public Oracle() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTextField2 = new javax.swing.JTextField(10);
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
getContentPane().add(jTextField2);
jTextField2.setBounds(250, 50, 240, 20);
jLabel2.setText("jLabel2");
getContentPane().add(jLabel2);
jLabel2.setBounds(150, 50, 80, 20);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
static int x, y;
static int number;
static JTextField T1[];
static JLabel L1[];
public static void main(String args[]) {
String str = JOptionPane.showInputDialog(null, "Enter Your host name/IP Addess"); //NOI18N
try {
Class.forName("oracle.jdbc.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@" + str + ":1521:xe", "system", "9415");
Statement s = conn.createStatement();
String Table = JOptionPane.showInputDialog("Enter Table Name for which Records You Want to see"); //NOI18N
ResultSet rs = s.executeQuery("select * from " +Table);
ResultSetMetaData rsmd = rs.getMetaData();
number = rsmd.getColumnCount();
L1=new JLabel[number];
T1=new JTextField[number];
for (int i = 0; i < number; i++) {
L1[i] = new JLabel();
T1[i] = new JTextField();
}
set();
rs.close();
conn.close();
} catch (ClassNotFoundException | SQLException ex) {
JOptionPane.showMessageDialog(null, ex);
}
/* Create and display the form */
java.awt.EventQueue.invokeLater(() -> {
new Oracle().setVisible(true);
});
}
public static void set(){
Oracle.jTextField2.setVisible(false);
x=jTextField2.getX();
y=jTextField2.getY();
for(int i=0;i<number;i++){
T1[i].setBounds(x, y*(i*25),jTextField2.getWidth(),jTextField2.getHeight() );
}
}
// Variables declaration - do not modify
private static javax.swing.JLabel jLabel2;
private static javax.swing.JTextField jTextField2;
// End of variables declaration
}