[ALIGN=RIGHT]اخواني الكرام ....
اخوكم مبتدأ في الجافا .. يطلب المساعدة منكم ...
قمت بالربط بالوراكل مع الجافا واظهرت البيانات في Textfields استخدمت button
في عملية التنقل بين البيانات ...
قد نجحت في عملية الإنتقال ل record التالي .. ولكن كيف يمكن العودة
ل record السابق ؟؟؟
import java.sql.*;
public class Oracle extends Frame implements ActionListener {
TextField t1,t2;
Button b1,b2,b3;
Label l1,l2;
FlowLayout f;
Color c,cb;
Connection connection;
Statement statement;
ResultSet result;
public Oracle() {
c = new Color(255,215,255);
f = new FlowLayout();
setLayout(f);
l1 = new Label("EmpNumber");
l1.setForeground©;
t1 = new TextField(3);
l2 = new Label("EmpName");
l2.setForeground©;
t2 = new TextField(8);
b1 = new Button("Next");
b1.addActionListener(this);
b2 = new Button("Exit");
b2.addActionListener(this);
b3 = new Button("Back");
b3.addActionListener(this);
cb = new Color(0,0,0);
setBackground(cb);
add(l1);add(t1);add(l2);add(t2);add(b1);add(b2);add(b3);
// Oracle Connection ..
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e){}
try{
connection = DriverManager.getConnection("jdbc:odbc:ORC_Library","scott","tiger");
statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
result = statement.executeQuery("select * from emp");
}
catch(SQLException e){
System.out.println(e.toString());
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()=="Exit")
System.exit(0);
if(e.getActionCommand()=="Next")
try{
result.next();
t1.setText(result.getString("empno"));
t2.setText(result.getString("ename"));
if(result.next()==false){
result.close();
statement.close();
connection.close();
}
}
catch(SQLException f)
{
System.out.println(f.toString());
}
if(e.getActionCommand()=="Back") {
try
{
result.deleteRow();
}
catch(SQLException q)
{
System.out.print(q.toString());
}
}
}
public static void main(String args[])
{
Oracle obj =new Oracle();
obj.setSize(400,100);
obj.show();
}
}