Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7018005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:59:14+00:00 2026-05-27T22:59:14+00:00

Good night all, this is my first question. i got some problem when running

  • 0

Good night all, this is my first question.

i got some problem when running ZK application with tomcat webserver

java.lang.ClassCastException: org.postgresql.jdbc4.Jdbc4Connection cannot be cast to controller.connection
controller.connection.(connection.java:27)
controller.lap_keuangan.lk_Controller.preparelistlk(lk_Controller.java:34)
controller.lap_keuangan.lk_Controller.doAfterCompose(lk_Controller.java:30)

this is my connection class:

package controller;

//import ommited


public class connection {

  private static final String url="jdbc:postgresql://192.168.56.101:5432/adempiere";
  private static final String user = "postgres";
  private static final String pwd = "auliaardy";
  private connection conn;

  public connection()throws Exception{
      try {
          DriverManager.registerDriver(new org.postgresql.Driver());
          conn =  (connection) DriverManager.getConnection(url,user,pwd);

      } catch (SQLException e) {
          System.out.println("Driver tidak ditemukan"+e);
      }
  }

  public Connection getConnection(){
      return (Connection) conn;
  }

  public void closeConnection(){
      try {
          conn.closeConnection();
      } catch (Exception e) {
          System.out.println("gagal menutup koneksi disebabkan: "+e);
      }
  }

  }

and this is my controller class

//import ommited here

public class lk_Controller extends GenericForwardComposer {

    private Listbox listlk;

    @Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp);
        preparelistlk();
    }

    public void preparelistlk() throws Exception {
        connection c = new connection();
        try {
            l_keuangan lk = new l_keuangan(c.getConnection());
            List<tbl_lk> llk = lk.getLKeuangan();
            ListModelList lml = new ListModelList(llk, true);
            listlk.setModel(lml);
            listlk.setItemRenderer(new ListitemRenderer() {

                @Override
                public void render(Listitem lslk, Object o) throws Exception {

                    try {

                        tbl_lk tl = (tbl_lk) o;
                        new Listcell(ubahtanggal()).setParent(lslk);
                        new Listcell(Integer.toString(tl.getSum_debit())).setParent(lslk);
                        new Listcell(Integer.toString(tl.getSum_credit())).setParent(lslk);
                        new Listcell(Integer.toString(tl.getTotal())).setParent(lslk);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public  String ubahtanggal() {
        tbl_lk lk = new tbl_lk();
        DateFormat df = new SimpleDateFormat("YYYY/MM/DD");
        long tanggal = lk.getTanggal().getTime();
        String tgl = df.format(tanggal);
        return tgl;




    }
}

tomcat said error at line:
DriverManager.registerDriver(new org.postgresql.Driver());
conn = (connection) DriverManager.getConnection(url,user,pwd);

i cant changed the cast connection to:
conn = DriverManager.getConnection(url,user,pwd);

please somebody help, i got stuck over night T.T

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:59:15+00:00Added an answer on May 27, 2026 at 10:59 pm

    The DriverManager object returns an implementation of java.sql.Connection. It won’t return an instance of your controller.connection class. Your conn variable should be of type java.sql.Connection.

    Note that:

    • classes in Java, by convention, always start with an upper-case letter
    • naming your class connection, and make it wrap an object of class Connection, is really really confusing. So confusing that you got confused by your own code.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've being trying this all night through. Is there any good solution to do
Good night everyone, This question leaves me a little embarassed because, of couse, I
Good morning, afternoon, evening or night (depending on your timezone). This is just a
Good evening I've got a little problem with my DataGridView in a .NET Windows
I don't know if this is a good place for such a question. If
good night i have a doubt what reason this output doesn't work [{var1:abc},{var2:abcd},{var3:abcde}] but
Good afternoon, This should be an easy one. I've done the cookie-cutter default ASP.NET
Good day, We just converted our web application .NET 1.1 to .NET 2.0. We
Good morning, I am the developer of a medium sized PDA application that will
I'm trying to get my head round this (okay, tbh cramming a night before

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.