Can you find the problem in this code?

I've searching some examples of the using of JTable on this forum.
So I've used a code found here.
But nothing happens, the JFrame doesn't appear on screen.
I'm sure my database "CLIENTES" exists inside the db folder. And also there's data inside "CLIENTES" table.
So, where is the problem then?
Thanks.
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
public class TelaPrincipal extends JFrame {
   public TelaPrincipal() {
        Vector columnNames = new Vector();
        Vector data = new Vector();
        try {
           //  Connect to the Database
           String driver = "org.hsqldb.jdbcDriver";
           String url = "jdbc:hsqldb:file:./db/CLIENTES";
           String userId = "sa";
           String password = "";
           Class.forName(driver);
           Connection connection = DriverManager.getConnection(url, userId, password);
           //  Read data from a table
           String sql = "SELECT * FROM CLIENTES";
           Statement stmt = connection.createStatement();
           ResultSet rs = stmt.executeQuery(sql);
           ResultSetMetaData md = rs.getMetaData();
           int columns = md.getColumnCount();
           //  Get column names
           for (int i = 1; i <= columns; i++){
              columnNames.addElement( md.getColumnName(i) );
           //  Get row data
           while (rs.next()) {
              Vector row = new Vector(columns);
              for (int i = 1; i <= columns; i++) {
                 row.addElement(rs.getObject(i));
              data.addElement(row);
           rs.close();
           stmt.close();
        catch(ClassNotFoundException cnfe) {
           cnfe.printStackTrace();
        catch(SQLException sqle) {
          sqle.printStackTrace(); 
        //  Create table with database data
        JTable table = new JTable(data, columnNames);
        JScrollPane scrollPane = new JScrollPane( table );
        getContentPane().add(scrollPane);
    public static void main(String[] args) {
       TelaPrincipal tp = new TelaPrincipal();
       tp.setDefaultCloseOperation(EXIT_ON_CLOSE);
       tp.pack();
       tp.setVisible(true);
}

the jdbc driver is not on the classpath?

Similar Messages

  • Ran hardware test and found error code 4SNS/1/40000001:YPOR-0.592 ? can't find the signification of this error code

    ran hardware test and found error code 4SNS/1/40000001:YPOR-0.592 ? can't find the signification of this error code.

    Back atcha!

  • What's the problem in this code

    import java.lang.reflect.*;
    import java.awt.*;
    class ABC
         public Integer i;
         ABC()
         public void setInt(Integer t)
              i = t;
    public class SampleName {
    public static void main(String[] args)
    ABC g1 = new ABC();
    g1.setInt(new Integer(10));
    printFieldNames(g1);
    static void printFieldNames(Object o) {
    Class c = o.getClass();
    Field[] publicFields = c.getDeclaredFields();
    for (int i = 0; i < publicFields.length; i++)
    try {
    Object ref = publicFields.get(c);
    System.out.println(" ref.toString() : " + ref.toString());
         }catch(Exception e)
                   e.printStackTrace();
    What is the problem with this code,at run time Iam getting this exception
    java.lang.IllegalArgumentException: object is not an instance of declaring class
    How can we get the value of field of an object

    Now it got this exception
    java.lang.IllegalAccessException
    at java.lang.reflect.Field.get(Native Method)That's strange - I didn't! ;-)
    Are you running exactly the same code as the code you posted (except for the one line I said to change)?

  • Vector, what is the problem with this code?

    Vector, what is the problem with this code?
    63  private java.util.Vector data=new Vector();
    64  Vector aaaaa=new Vector();
    65   data.addElement(aaaaa);
    74  aaaaa.addElement(new String("Mary"));on compiling this code, the error is
    TableDemo.java:65: <identifier> expected
                    data.addElement(aaaaa);
                                   ^
    TableDemo.java:74: <identifier> expected
                    aaaaa.addElement(new String("Mary"));
                                    ^
    TableDemo.java:65: package data does not exist
                    data.addElement(aaaaa);
                        ^
    TableDemo.java:74: package aaaaa does not exist
                    aaaaa.addElement(new String("Mary"));Friends i really got fed up with this code for more than half an hour.could anybody spot the problem?

    I can see many:
    1. i assume your code snip is inside a method. a local variable can not be declare private.
    2. if you didn't import java.util.* on top then you need to prefix package on All occurance of Vector.
    3. String in java are constant and has literal syntax. "Mary" is sufficient in most of the time, unless you purposly want to call new String("Mary") on purpose. Read java.lang.String javadoc.
    Here is a sample that would compile...:
    public class QuickMain {
         public static void main(String[] args) {
              java.util.Vector data=new java.util.Vector();
              java.util.Vector aaaaa=new java.util.Vector();
              data.addElement(aaaaa);
              aaaaa.addElement(new String("Mary"));
    }

  • When I click "about this mac" to check on my storage, I get a number of different sections music, movies, etc. but also I get a section called backups, where can I find the files in this section?

    When I click "about this mac" to check on my storage, I get a number of different sections music, movies, etc. but also I get a section called backups, where can I find the files in this section?

    Welcome to Apple Support Communities
    All the storage in "Backups" is taken up by local snapshots, which are made automatically in all MacBooks, MacBooks Pro and MacBooks Air with OS X Lion or newer and Time Machine turned on.
    See > http://pondini.org/TM/30.html I recommend you to leave them there, because they will be removed automatically. However, if you want, you can disable or remove them manually if you want, even if there's no reason to do this. Have a look at the link above for more information

  • Where can I find the relation between company code and plant?

    where can I find the relation between company code and plant?
    I need to the list of plants under a company code.
    Which table?

    yes,wayne weng   .What you said is right.
    Thank you very much!
    My MSN:[email protected]

  • I HAVE TO INSTAL A PRODUCT C LLED "KUDANI AIR " . FAILURE TO DO SO IS BASED ON  ADOBE AIR , SO I AM TOLD . HOW CAN I MAKE SURE THAT IS THE CASE ?? HOW CAN I SOLVE THE PROBLEM IF THIS IS THE CASE ??

    I HAVE TO INSTALL A PRODUCT CALLED "KUDANI AIR " . FAILURE TO DO SO IS BASED ON  ADOBE AIR , SO I AM TOLD . HOW CAN I MAKE SURE THAT IS THE CASE ?? HOW CAN I SOLVE THE PROBLEM IF THIS IS THE CASE ??

    if you try to install an app that depends on adobe air, you should be prompted to download and install adobe air (unless it's already installed).
    you can download and install directly so you're not prompted by that app, Adobe - Adobe AIR

  • Please tell me what is the problem with this code

    Hai,
    Iam new to Swings. can any one tell what is the problem with this code. I cant see those controls on the frame. please give me the suggestions.
    I got the frame ,but the controls are not.
    this is the code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ex2 extends JFrame
    JButton b1;
    JLabel l1,l2;
    JPanel p1,p2;
    JTextField tf1;
    JPasswordField tf2;
    public ex2()
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setTitle("Another example");
    setSize(500,500);
    setVisible(true);
    b1=new JButton(" ok ");
    p1=new JPanel();
    p1.setLayout(new GridLayout(2,2));
    p2=new JPanel();
    p2.setLayout(new BorderLayout());
    l1=new JLabel("Name :");
    l2=new JLabel("Password:");
    tf1=new JTextField(15);
    tf2=new JPasswordField(15);
    Container con=getContentPane();
    con.add(p1);
    con.add(p2);
    public static void createAndShowGUI()
    ex2.setDefaultLookAndFeelDecorated(true);
    public static void main(String ar[])
    createAndShowGUI();
    new ex2();
    }

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ex2 extends JFrame
        JButton b1;
        JLabel l1,l2;
        JPanel p1,p2;
        JTextField tf1;
        JPasswordField tf2;
        public ex2()
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setTitle("Another example");
            b1=new JButton(" ok ");
            p1=new JPanel();
            p1.add(b1);
            p2=new JPanel();
            p2.setLayout(new GridLayout(2,2));
            l1=new JLabel("Name :");
            l2=new JLabel("Password:");
            tf1=new JTextField(15);
            tf2=new JPasswordField(15);
            p2.add(l1);
            p2.add(tf1);
            p2.add(l2);
            p2.add(tf2);
            Container con=getContentPane();
            con.add(p1, BorderLayout.NORTH);
            con.add(p2, BorderLayout.CENTER);
            pack();
            setVisible(true);
        public static void createAndShowGUI()
            ex2.setDefaultLookAndFeelDecorated(true);
        public static void main(String ar[])
            createAndShowGUI();
            new ex2();
    }

  • Can you see the problem?

    i'm trying to write a simple image viewer application.
    Can you see the problem. i can't. i'll appreciate any advice or help?
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import java.io.*;
    public class SimpleViewer extends Frame {
         protected Image awtImage;
         public void loadAndDisplay(String filename) {
              Image img = readImage(filename);
              awtImage = img;
              int width = img.getWidth(this);
              int height = img.getHeight(this);
              displayImage(img, width, height);
         public void displayImage(Image img, int width, int height) {
              addWindowListener(
                   new WindowAdapter() {
                        public void windowClosing(WindowEvent e){
                             System.exit(0);
              setTitle("Simple Viewer ");
              pack();
              setSize(new Dimension(width, height));
              show();
              repaint();
         public image readImage(String filename) {
              Image image = Toolkit.getDefaultToolkit().getImage(imageName);
              MediaTracker imageTracker = new MediaTracker(this);
              imageTracker.addImage(image, 0);
              try{
                   imageTracker.waitForID(0);
              }catch(InterruptedException e){ return null;}
              return image;
         public void paint(Graphics g){
              Rectangle rect = this.getBounds();
              if(awtImage != null) {
                   g.drawImage(awtImage, 0,0,rect.width, rect.height, this);
         public static void main(String[] args){
              SimpleViewer ip = new SimpleViewer();
              if(args.length <1) {
                   System.out.println("Enter a valid image file name");
                   System.exit(0);
              ip.loadAndDisplay(args[0]);
    }

    check this line and tell me what you see... after all, it's the source of your compiler errors...
    public image readImage(String filename) {
              Image image = Toolkit.getDefaultToolkit().getImage(imageName);once you figure that out, it will work...
    ( hint : check variable names and capitalization of names )
    - MaxxDmg...
    - ' He who never sleeps... '

  • I was trying to make a purchase from Amazon & a return but FIREFOX would not let me open drop down boxes in the purchase & return areas. I was forced to use IE to accomplish the deed. Can you investigate the problem?

    I was trying to make a purchase from Amazon & a return but FIREFOX would not let me open drop down boxes in the areas. I was forced to use IE to accomplish the deed. Can you investigate the problem? Thanx, David Deters

    Thanks for the welcome Karsten! I’ve checked the installer disks – which appear to have all the main pieces of software, but not iDVD. If you or anyone knows where it might be hidden that would be great. Thanks for all the other info too!
    Thanks Lennart – I don’t think my computer could support iLife ’05 as it is running Mac OSX 10.3.2 and I’ve just been looking at its system requirements which state it requires 10.3.4 minimum – if you know differently, please let me know. As an alternative I have considered getting iLife ’04, but your comment about iLife ’05 being the first version to support external drives worried me (“iDVD 5 is the first iDVD version that officially supports external burners“ does this mean there is an unofficial option for iLife ‘04? Perhaps a patch similar to the one mentioned by Karsten), does that mean iLife ’04 would not support an external Lacie DVD writer?
    What is the earliest version of Toast I’d be able to use (as a money saving option!)?
    Thank you both, and apoligies for my amateurish questions…
    Kevin.

  • I can't put numbers on the decimals. It only allow ,00 as decimals. If i put 33.00 it's ok but i i put 33.44 when i press enter changes to 3344 as an entire number, i've try everything and can't find the solution. This should be a basic thing.

    I can't put numbers on the decimals. It only allow ,00 as decimals. If i put 33.00 it's ok but if i put 33.44 when i press enter changes to 3344 as an entire number, i've try everything and i can't find the solution. This should be a basic thing. How frustrating !!

    pedrofromsydney wrote:
    €          55,555.00
    that's the result i get. Still why can't i just type for ex. 29.55 and stay like that on the cell ? Why does it always change to 2955 or 2955.00. ??
    I don't understand this
    It appears you have the cell formatted to Currency, with the default two decimal places.
    What I don't understand, though is how Numbers arrived at a result of fifty five thousand five hundred fifty five on your entering the exact keystrokes in Yvan's post:
    an equals sign, followed by five ones, followed by a forward slash, followed by a 2.
    Here's the result I get:
    Could you do the following:
    Open a NEW Numbers document using the Blank template.
    Drag the Row and Column control (bottom right corner) to reduce the table to two columns and three rows.
    Enter the words "My table" in cell A1.
    Click on cell B2 to select it, then enter the formula 
    =11111/5
    Use only those eight keystrokes; do not include any commas, periods or other characters not shown.
    Click on B2 again to select it.
    Open the inspector and choose the Cell Format button.
    Do not make any changes in the Inspector window.
    Drag the Inspector window to the position shown in my screen shot.
    Take a screen shot that includes the Formula bar, the Table (with cell B2 selected) and the Cell Format Inspector pane (the same screen area as in my screen shot above).
    Post the screen shot in a reply to this post.
    I'm hoping there will be some clues as to what's happening here in the screen shot. Procedure for taking and posting a shot of part of the screen follows.
    Regards,
    Barry
    SCREEN SHOTS (Selected area)
    Place the mouse pointer at the top left corner of the area you want to include.
    Press shift-command-4.
    The mouse pointer will change to a plus sign on a circle.
    Hold down the mouse button and drag to the bottom right corner of the area you wan to capture.
    Release the mouse button.
    The screen shot will be saved to your desktop with the name "Picture 1" (The number will be different if you have taken other screen shots).
    POSTING
    In the Compose frame, place the Insertion point at the location you want the picture to be inserted.
    Click the camera icon above the compose frame to open the Insert Image dialogue.
    Click Choose file to open the Choose dialogue.
    If necessary, navigate to the Desktop and click on the 'by date column header to sort the files by date, most recent at the top.
    Select the most recent picture file.
    Click Choose.
    Wait for the picture's file name to appear beside Choose file.
    Click insert image.
    Done.
    B.

  • HT5312 How can you find the link to get a rescue email?

    How can you find the link to get a rescue email?
    I am not a regular user - and wonder why????
    Been at this for hours, can't remember questions, support sends you to the questions you can't answer or I would have the first time, or a promise of a link which doesn't seem to exist!!
    Now locked out!

    You need to contact Apple, either through the link in that article or by phoning them and asking for the Account Security team.
    (80167)

  • I am a student who subscribed to the 9.99 photography package, I didn't realize there was a discount for students.  I would like to upgrade to the full package with the student discount.  I can not find the option for this. How do I do this?

    I am a student who subscribed to the 9.99 photography package, I didn't realize there was a discount for students.  I would like to upgrade to the full package with the student discount.  I can not find the option for this. How do I do this?

    Hi Djmontanalv,
    Please go through the link below.
    http://helpx.adobe.com/x-productkb/policy-pricing/cancel-membership-subscription.html
    Regards,
    Anand

  • Can you find the fields

    hi all
    please can you find the fields from which table.These are the fields
    PUR.ORG
    PUR.GROUP
    TOTAL NET PRICE.
    P.O NUMBER.
    ITEM NO.
      MAT.NO.
       MATERIAL DES.
      ORDER QTY.
    NET PRICE.

    Hi Kiran,
    Check tables<b> EKKO</b> and <b>EKPO</b> to get the above fields.
    <b>PUR.ORG</b>  -  EKKO-EKORG
    <b>PUR.GROUP</b>  -  EKKO-EKGRP
    <b>TOTAL NET PRICE</b>  -  EKPO-NETWR
    <b>P.O NUMBER.</b> - EKKO-EBELN
    <b>ITEM NO.</b>   - EKPO-EBELP
    <b>MAT.NO.</b>  - EKPO-MATNR
    <b>MATERIAL DES.</b>  -
    <b>ORDER QTY.</b> - EKPO-MENGE
    <b>NET PRICE.</b>  - EKPO-NETPR
    Thanks,
    Vinay

  • I purchased FrameMaker 10.0 Windows Upgrade License from FM9 and I can't find the download for this.

    I purchased FrameMaker 10.0 Windows Upgrade License from FM9 and I can't find the download for this.

    Get in touch with support if it doesn't show up on your Adobe account.
    Mylenium

Maybe you are looking for