Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void actionPerformed(ActionEvent evt) {
- // TODO Auto-generated method stub
- String action = evt.getActionCommand();
- if(action.equals("first"))
- {
- firstNavigation();
- }else if(action.equals("Prev"))
- {
- preNavigation();
- }else if(action.equals("next"))
- {
- nextNavigation();
- }else if(action.equals("last"))
- {
- lastNavigation();
- }
- }
- private void firstNavigation()
- {
- try{
- String url ="jdbc:mysql://localhost/opgavei";
- Class.forName("com.mysql.jdbc.Driver");
- Connection con = DriverManager.getConnection(url, "root", "" );
- //Connection con = null;
- if(rs == null)
- {
- String sql = ("SELECT * FROM tapijtbestelling");
- Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
- ResultSet.CONCUR_UPDATABLE);
- rs = st.executeQuery(sql);
- }
- if(rs.first())
- {
- populateValue();
- }
- }catch(Exception e)
- {
- JOptionPane.showMessageDialog(null, e.getMessage(),"Error",
- JOptionPane.ERROR_MESSAGE);
- }
- }
- private void preNavigation()
- {
- try{
- String url ="jdbc:mysql://localhost/opgavei";
- Class.forName("com.mysql.jdbc.Driver");
- Connection con = DriverManager.getConnection(url, "root", "" );
- if(rs == null)
- {
- String sql = ("SELECT * FROM tapijtbestelling");
- Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
- ResultSet.CONCUR_UPDATABLE);
- rs = st.executeQuery(sql);
- }
- if(rs.previous())
- {
- populateValue();
- }
- }catch(Exception e)
- {
- JOptionPane.showMessageDialog(null, e.getMessage(),"Error",
- JOptionPane.ERROR_MESSAGE);
- }
- }
- private void nextNavigation()
- {
- try{
- String url ="jdbc:mysql://localhost/opgavei";
- Class.forName("com.mysql.jdbc.Driver");
- Connection con = DriverManager.getConnection(url, "root", "" );
- if(rs == null)
- {
- String sql = ("SELECT * FROM tapijtbestelling");
- Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
- ResultSet.CONCUR_UPDATABLE);
- rs = st.executeQuery(sql);
- }
- if(rs.next())
- {
- populateValue();
- }
- }catch(Exception e)
- {
- JOptionPane.showMessageDialog(null, e.getMessage(),"Error",
- JOptionPane.ERROR_MESSAGE);
- }
- }
- private void lastNavigation()
- {
- try{
- String url ="jdbc:mysql://localhost/opgavei";
- Class.forName("com.mysql.jdbc.Driver");
- Connection con = DriverManager.getConnection(url, "root", "" );
- if(rs == null)
- {
- String sql = ("SELECT * FROM tapijtbestelling");
- Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
- ResultSet.CONCUR_UPDATABLE);
- rs = st.executeQuery(sql);
- }
- if(rs.last())
- {
- populateValue();
- }
- }catch(Exception e)
- {
- JOptionPane.showMessageDialog(null, e.getMessage(),"Error",
- JOptionPane.ERROR_MESSAGE);
- }
- }
- private void populateValue() throws Exception
- {
- txt1.setText(rs.getString("BestelCode"));
- txt2.setText(rs.getString("BestelDatum"));
- txt3.setText(rs.getString("Tapijtcode"));
- txt4.setText(rs.getString("Lengte"));
- txt5.setText(rs.getString("Breedte"));
- }
Add Comment
Please, Sign In to add comment