Creating columns in tables through variables in java

Asked

Viewed 199 times

1

Hello, I would like the help to solve the following problem: I have a table, but its columns can be defined by user-defined variables. For example, the user defines a1, B1 and C1, from which the program creates a table that must contain a column for each variable. Thus, the user can set up to n columns. To build the table I am using netbeans interfaces. I’m trying to find a solution to this for a while .... someone could help me?

  • 1

    Welcome to sopt. What have you tried to do? It would be interesting to add what you have already tried in the question, for a future solution to have where to start.

  • Dude, I don’t know your solution, but creating new columns in the bank has a 99.999999% chance of having a better way to do what you want. DDL commands should never be available to users.

1 answer

1

Do not create columns. If you need the user to create variables and specify various values for each of them, create a new table that allows you to define the variables for each user. The fields are:

  • User id
  • Variable name

Then create another table to store the values, with the fields:

  • User id
  • Variable name
  • Variable value

So in this second table, it can have several values.

If the user can set only one value per variable, simply use a new table as the last:

  • User id
  • Variable name
  • Variable value
  • Thanks, I’ll try to solve and go back to a feed back.

  • One thing I forgot to mention, I’m not messing with databases. And the table is being made by the graphical interface of neatbeans, I would like to try to create the columns in a "dynamic"

Browser other questions tagged

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