![]() a numeric ID populated via MySQL's auto-increment feature. You should not merge columns in this way because you are making it hard to use these pieces of information individually.Īlso, as Jeanne says, it's not clear what your PK is on the USER table. You have a column in your SQL called "account_type_account_name": are you sure about this? It looks like it should be two separate columns - ACCOUNT_TYPE and ACCOUNT_NAME. Ps2.setString(2, account.getAccountName()) Ps2.setString(1, account.getAccount_id()) Would it make sense to create another class for the second time? I have followed your suggestions however the application still only saving information to one table. Ps2.setString(14, account.getAccountName()) Ps2.setString(13, account.getAccount_id()) Ps2 = connection.prepareStatement(queryAccount) Ps = connection.prepareStatement(queryUser) "INSERT INTO account (account_id, account_type_account_name) " + "phone, address, city, state, country, zip, role_userRole) " "INSERT INTO user (fName,lName, emailAddress, password, dateOfBirth, " Public static int insert(User user, Account account)ĬonnectionPool pool = ConnectionPool.getInstance() Ĭonnection connection = pool.getConnection() ![]() I suppose I have to use two different preparedStatement within the same Insert method but I'm not really, plus it doesn't work.Īny ideas on how to solve this where I can research to find the solution. I'm new to JDBC and haven't been able to find documentation on how to add data to two tables using the same insert method. However, I 'm having problems to the second table which has the FK from the first table. I have successfully inserted data to to the parent table. I have two different tables in a MySQL DB.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |