In MySQL how should the data types be declared in case of using the following elements in JAVA

0

1) If you are going to create a password with JPasswordField, what type of data should be declared in the SQL database ... would it be varchar or another? I understand that the passwords are encrypted and ask for another type of data.

2) In the case of JComboBox what type of data would be received in the database?

3) In case of RadioButtom or CheckBox ??

4) Should you have a space to save a user's picture as it would be created? I think there are two ways, no? that of adding the image as such a binary or something like that ... and the other one that would only add the path in that case the data would be varchar or text type? sometimes the routes can be long .. D:

5) Dates from Java with jcalendar to mysql date can you? how?

Thanks for your help I'm starting I'm doing a project with Java in NetBeans and with phpMyAdmin

    
asked by HeckDan 18.05.2017 в 03:41
source

2 answers

2
  • The password can be inserted as text by taking the value of the JPasswordField field, so you can use varchar . For reasons of security you could encrypt the password first before inserting it in the Database. For this you can use for example MD5 , although it may not be the safest of all (but it's one way).
  • For the JComboBox you can use several types depending on the value of your Combo. (We know that ComboBoxes can store several types such as Integer , String , ...)
  • In case of RadioButton or CheckBox you can use tinyint(1) . The value 0 is considered false , and the value 1 is considered true .
  • To save a photo I recommend saving the photo to the host, and insert the path in the database. For this, depending on the size of the routes of your images, you will use varchar or text (You should arrive with varchar by its limit of up to 8000 characters ).
  • Dates in MySQL are controlled with datetime .
  • answered by 23.05.2017 в 11:19
    0

    When you take the value of the password field, pass it to String and this way you make sure you insert a string.

    From the combo box you will use the value and therefore it will be a string, the same in case of radiobutton and checkbox.

    The photo I would keep as a chain that is the path of the image.

    And as for the dates I would not know how to work because I have not used JCalendar

        
    answered by 23.05.2017 в 10:59