skip to Main Content

Create ArrayList from Postgresql query

I have following class: public class Person { private String firstName; private String lastName; private List<String> habits; } I have Postgres query which returns me following result using inner join from 2 tables name | lastname| habits -------------------------------------- John |…

VIEW QUESTION

My Id is autoIncrement and other than Id from 1st position, I want to insert the name,price – Mysql

This is the code where I'm trying to use the insert query: int insertItems(String name,double amt,String exp)throws Exception{ Connection con=getConnection(); PreparedStatement ps=con.prepareStatement("insert into itemsList (null,name,amt,expire) values (?,?,?,?);");//when I use the 4?s it displays [Exception in thread "main" java.sql.SQLException: No value…

VIEW QUESTION

How can I check if accountNumber (non primary key) already exists in my database? – Mysql

String accountQuery = "insert into Account (accountNumber,currentBalance,type,personId) values (?,?,?,?);"; PreparedStatement accountPs = null; try { // These are my prepare Statements for my queries accountPs = conn.prepareStatement(accountQuery); // accountPs.setInt(1, personId.getPersonId()); accountPs.setInt(1, accountHolder.getAccountNumber()); accountPs.setDouble(2, accountHolder.getCurrentBalance()); accountPs.setString(3, accountHolder.getType()); accountPs.setInt(4, personId.getPersonId()); accountPs.executeUpdate(); accountPs.close();…

VIEW QUESTION
Back To Top
Search