Please tell me how to solve the error from the code. I want to get the details from the ms access table. I have used data and description as columns. date is the primary key in ms access. so please let me help me with reading the data from ms access table.
try{
connect();
stmt = (Statement) conn.createStatement();
String sql, ks = " ";
ks = JOptionPane.showInputDialog("enter the date of which you want to read");
String jk = " where date=" + ks;
sql = "SELECT [date],[description] FROM Table2" + jk;
System.out.println("1");
rs = ((java.sql.Statement) stmt).executeQuery(sql);
if(rs.next())
{
String date1="hello",description1="hii";
date1 = rs.getString("date");
description1=rs.getString("description");
JOptionPane.showMessageDialog(null,"Date:"+date1+"\n"+description1);
}
else
{
JOptionPane.showMessageDialog(null,"Sorry the record does not exist");
try
{
close();
}
catch(Exception ea)
{
JOptionPane.showMessageDialog(null, "Error:"+ea.getMessage());
}
}
}
catch(Exception ew)
{
JOptionPane.showMessageDialog(null, "Unable to fetch Data");
JOptionPane.showMessageDialog(null,""+ew.getMessage());
System.out.println(""+ew);
}
Thanks