I am making a program on library management but in my program I am getting the error when I am extracting the date from MySQl(my database).
Below is the short piece of code where I am getting the error.

Calendar c1=Calendar.getInstance();

ResultSet rs=stm.executeQuery("Select AccessionNumber,Name,Fine,DueDate from issuer natural join classinfo;");



 java.sql.Date d1;
 
 
 d1=rs.getDate("DueDate");
 //I am getting error here in executing above line as verified by the below message. I am not seeing the below message means above line is not compiled successfully.
 
 JOptionPane.showMessageDialog(null,"CHECK 1");
 

java.util.Date d1j=(java.util.Date)d1;


c1.setTime(d1j);

I am having the following type of data in the column "DueDate" :

2010-02-15
2009-05-20

and the datatype of the above data is also date in MYSQL server.

Below is the complete code of my program.

int accno=Integer.parseInt(accnoTF.getText());
float finePERDAY=0;
double TotalFine=0;
int DueMonth=0;
int DueYear;
int DayofYear=0;
int daysInYear=0;





try{
Class.forName("java.sql.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3307/library","root","124");
Statement stm=conn.createStatement();




String dispName="";
String dispBooktitle="";
String dispClass="";
Date dispDuedate;
Date dispIssuedate;
int check=0;

Calendar c1=Calendar.getInstance();

ResultSet rs=stm.executeQuery("Select AccessionNumber,Name,Fine,DueDate from issuer natural join classinfo;");



 java.sql.Date d1;
 
 
 d1=rs.getDate("DueDate");
 //I am getting error here in executing above line as verified by the below message. I am not seeing the below message means above line is not compiled successfully.
 
 JOptionPane.showMessageDialog(null,"CHECK 1");
 

java.util.Date d1j=(java.util.Date)d1;


c1.setTime(d1j);

DueYear=c1.get(Calendar.YEAR);
DueMonth=c1.get(Calendar.MONTH);
DayofYear=c1.get(Calendar.DAY_OF_YEAR);

int tempaccno=0;
while(rs.next()){

tempaccno=rs.getInt("AccessionNumber");

if(accno==tempaccno){
dispName=rs.getString("Name");
dispClass=rs.getString("Class");    
dispIssuedate=rs.getDate("IssuedOn");
dispDuedate=rs.getDate("DueDate");
finePERDAY=rs.getFloat("Fine");
TotalFine=calculateFine(finePERDAY, DueYear,DueMonth,DayofYear);
infoTA.append("FINE INFORMATION\n Name\t"+dispName+"\nClass\t"+dispClass+"\nIssueDate\t"+dispIssuedate+"\nDueDate\t"+dispDuedate+"\nCurrent Date\t"+"\n\nSo, fine till date\t"+TotalFine);

check=1;
}


}

rs.close();



if(check==0)
    JOptionPane.showMessageDialog(null,"There was no such book having "+accno+" as an Accession Number. Please check again carefully.");


}catch(Exception e){
JOptionPane.showMessageDialog(null,"Error in connectivity");
}

Post the complete exception stack trace and if possible *formatted* source code.

This is the formatted code and please please tell me the code, I am having the project on libraray management and this is the only thing that is making me not to proceed in my project.

What exception? The full stack trace please.

And don't do

catch(Exception e){
    JOptionPane.showMessageDialog(null,"Error in connectivity");
}

Show the actual exception not some meaningless string.

Edit: Or, at least, not only the meaningless String.

com.mysql.jdbc.ResultSetImpl.getDate(resultSetImpl.java:2107,2067,2131,218)
this is the stack trace.....

btw what is the significance of stack trace

That is not the complete stacktrace. A complete stack trace helps us know the call stack state during the time the exception was dumped on to the STDOUT/STDERR. A complete stack trace looks like:

org.omg.CORBA.MARSHAL: com.ibm.ws.pmi.server.DataDescriptor; IllegalAccessException minor code: 4942F23E completed: No
at com.ibm.rmi.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:199)
at com.ibm.rmi.iiop.CDRInputStream.read_value(CDRInputStream.java:1429)
at com.ibm.rmi.io.ValueHandlerImpl.read_Array(ValueHandlerImpl.java:625)
at com.ibm.rmi.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:273)
at com.ibm.rmi.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:189)
at com.ibm.rmi.iiop.CDRInputStream.read_value(CDRInputStream.java:1429)
at com.ibm.ejs.sm.beans._EJSRemoteStatelessPmiService_Tie._invoke(_EJSRemoteStatelessPmiService_Tie.java:613)
at com.ibm.CORBA.iiop.ExtendedServerDelegate.dispatch(ExtendedServerDelegate.java:515)
at com.ibm.CORBA.iiop.ORB.process(ORB.java:2377)
at com.ibm.CORBA.iiop.OrbWorker.run(OrbWorker.java:186)
at com.ibm.ejs.oa.pool.ThreadPool$PooledWorker.run(ThreadPool.java:104)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:137)

i also made library management project which uses the date and calender for fine calculation,etc . you have to use proper flow of coding as start over packages which used inth following cod,etc

hi sachin, can you help me in making my project. I have done almost everything now what is left is only this thing.................that is getting date from mysql and other small things................

do you have a facebook account...or plz tell me ur email ID

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.