How to define the data types of the columns of a Jtable equal to the Mysql database?

Asked

Viewed 21 times

-2

I created a graphical user interface in Netbeans where I inserted a Jtable into a Jframe FORM. I have a Mysql database whose columns are:

Id: Integer

Name: String

Active: Boolean

But when I use: jTable.setModel(DbUtils.resultSetToTableModel()) (RS2XML.jar library method), Jtable is filled all as String.

How do I get Jtable to be populated with the correct data types equal to the database (Integer, String and Boolean)?

1 answer

0

Just use the parse. For example, you have a String variable but in the database it is int, you put: int x = Integer.parseint(String variable);

so you will have a variable of the same type as your bank.

  • There is no way to do so, because the resultToTableModel() method already plays the values directly in the table.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.