3

Right now I'm creating a dashboard; I need to fill a JTable with info from an MS-Access database, for that purpose I'm using this code.

try {
    con3 = Connectionz3.getConnection();//Connection Object 
    String dashboard2 = "Select * FROM [First_Entry]";
    pst3 = con.prepareStatement(dashboard2);
    rs3 = pst3.executeQuery();
    dtabla.setModel(DbUtils.resultSetToTableModel(rs3));

    PrinMenu.setVisible(false);
    Dashboard.setVisible(true);
}
catch (SQLException ex) {
        Logger.getLogger(Signin_Panel.class.getName()).log(Level.SEVERE, null, ex);
}

And I get the error:

SEVERE: null
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.4 user lacks privilege or object not found: FIRST_ENTRY

The weird thing is that I'm calling the same database using this code:

    con2 = Connectionz2.getConnection(); //Connection Object
    String query = "INSERT INTO [First_Entry](Entry_ID, Entrydate, Category_Call, VA_Creator, Name_Creator, VA_Agent, Name_Agent, Call_Date, Call_ID, q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,q14,q15,q16,q17,q18)" +
"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

    PreparedStatement preparedStmt = con2.prepareStatement(query);
    preparedStmt.setInt(1, 0);
    preparedStmt.setString(2,cdate);
    preparedStmt.setString(3, Catcall);
    preparedStmt.setString(4, userva);
    preparedStmt.setString(5, fname+" "+lname);
    preparedStmt.setString(6,agentva);
    preparedStmt.setString(7,agentname);
    preparedStmt.setString(8, dotc);
    preparedStmt.setString(9, callid);
    preparedStmt.setInt(10, quest1);
    preparedStmt.setInt(11, quest2);
    preparedStmt.setInt(12, quest3);
    preparedStmt.setInt(13, quest4);
    preparedStmt.setInt(14, quest5);
    preparedStmt.setInt(15, quest6);
    preparedStmt.setInt(16, quest7);
    preparedStmt.setInt(17, quest8);
    preparedStmt.setInt(18, quest9);
    preparedStmt.setInt(19, quest10);
    preparedStmt.setInt(20,quest11);
    preparedStmt.setInt(21,quest12);
    preparedStmt.setInt(22,quest13);
    preparedStmt.setInt(23,quest14);
    preparedStmt.setInt(24,quest15);
    preparedStmt.setInt(25,quest16);
    preparedStmt.setInt(26,quest17);
    preparedStmt.setInt(27,quest18);

    preparedStmt.execute();

    con2.close();

And this time it works.

I don't know if maybe I'm calling the object in the wrong way. I tried to change the location, change the name of the table but is not working. Using other database to fill the JTable works without any problem, any suggest?

marc_s
  • 675,133
  • 158
  • 1,253
  • 1,388

1 Answers1

1

It looks like your issue is here:

con3 = Connectionz3.getConnection();//Connection Object 
String dashboard2 = "Select * FROM [First_Entry]";
pst3 = con.prepareStatement(dashboard2);

Note how you define con3 on the first line above, then on the third line above you use con instead of con3.

So change the third line to: pst3 = con3.prepareStatement(dashboard2);

sorifiend
  • 4,546
  • 1
  • 25
  • 39