This tutorial will teach you how to make Record Navigation using Java Mysql.
First we have to Connect to Database create the method connect()
public void connect()
{
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/apocompany","root","");
stat = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = stat.executeQuery("select id,custname,loantype,amount from loan");
} catch (ClassNotFoundException ex)
{
ex.printStackTrace();
}
catch (SQLException ex) {
ex.printStackTrace();
}
} after that call the method inside constructor of class i shown below.
public LoanNav() {
initComponents();
connect();
} Create the First Button paste code inside the button
try
{
rs.first();
txtid.setText(rs.getString(1));
txtname.setText(rs.getString(2));
txtltype.setText(rs.getString(3));
txtamount.setText(rs.getString(4));
} catch (SQLException ex) {
} Create the Last Button paste code inside the button
try
{
if(!rs.isLast())
{
rs.next();
txtid.setText(rs.getString(1));
txtname.setText(rs.getString(2));
txtltype.setText(rs.getString(3));
txtamount.setText(rs.getString(4));
}
} catch (SQLException ex) {
} Create the Next Button paste code inside the button
try
{
if(!rs.isLast())
{
rs.next();
txtid.setText(rs.getString(1));
txtname.setText(rs.getString(2));
txtltype.setText(rs.getString(3));
txtamount.setText(rs.getString(4));
}
} catch (SQLException ex) {
} Create the Previous Button paste code inside the button
try
{
if(!rs.isFirst())
{
rs.previous();
txtid.setText(rs.getString(1));
txtname.setText(rs.getString(2));
txtltype.setText(rs.getString(3));
txtamount.setText(rs.getString(4));
}
} catch (SQLException ex) {
}
What Is the Tesla Pi Phone? Imagine if Tesla, the company that makes famous…
Inventory Management POS systems are now an essential part of modern businesses such as bookshops,…
If you're just beginning to learn Java GUI programming creating an Water System Calculator is a fantastic project for…
GitHub is a powerful tool used by teams and developers around the globe. This guide is…
It's like having a super-smart buddy that is always there to help you write stories,…
The UK is known for its rich history, diverse culture, and most of all its…