Skip to content
Advertisement

Tag: sql

having trouble inserting values into table with syntax error

Everytime at around “composedLine = String.format(“%s, %s, %s, %s, %s”, composedLine, values[0], values[1], values[2], values[3]);” it produces “INSERT INTO airport VALUES (, ABR, Aberdeen Regional Airport, Aberdeen” instead of “INSERT INTO airport VALUES (ABR, Aberdeen Regional Airport, Aberdeen” which causes a syntax error when I use executeupdate due to the “,” before the ABR. Answer This code is a security

JPA Cast BigDecimal as string

I’m using JPA to query a database, but something strange happens. In some cases the cast works and compiles fine, but with a BigDecimal it doesn’t let me use the cast to make a LIKE with a String. Here is a part of the code that works: pesoObjetivo is a data type Double But when I try to perform the

PostgreSql unable to resolve table user

My problem is that intellij raise an error that unable to resolve table user. Table is created in database it can be seen in database in Intellij but it looks like compiler doesn’t have an access to it. Did someone have similiar problem? enter image description here Answer If you can confirm that the table exists and you connect to

Change a line to prepared statement

I have this line and I am trying to do this line prepared statement but I am not able to do it. What I did is this : the sql table is this Answer This folwoing code should be encapsuled in a ty catch statment Also i hope you add a password hashing function to your code, every thing else

Checking for overlapping appointments in database not working?

I’m saving appointments to a database and have a method that checks if times are overlapping. I’m calling the method using I don’t receive any errors when saving appointments although they can be for the same exact times. I’m converting a LocalTime to a ZonedDateTime to save in the DB by using Timestamp.valueOf(startDateTimeZDT.toLocalDateTime() Timestamp.valueOf(endDateTimeZDT.toLocalDateTime() I can’t seem to find out

Getting UNIQUE constraint failed: tbl_data.id (Sqlite code 1555 SQLITE_CONSTRAINT_PRIMARYKEY) error in android studio room

I’m getting this error while i have initialize the id as primary key and i added the unique attribute. Data class code : Data Base Class code : and main activity code : and full error in logat : 2021-11-07 12:20:45.070 24994-24994/com.mohajer.kitset2 E/AndroidRuntime: FATAL EXCEPTION: main Process: com.mohajer.kitset2, PID: 24994 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mohajer.kitset2/com.mohajer.kitset2.MainActivity}: android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed:

JOOQ Forced types to convert a BigInteger to BigDecimal for POSTGRES

for a Table , lets say myTable, I have a column myColumn.. the default JOOQ generation creates myColumn as BigInteger, I want to create it as BigDecimal. This is the converter I am using. How should be the forceType configuration look like in the XML file? Answer The reason why your columns are generated as BigInteger is because they’re of

Select all employees sorted by last name in ascending order

How can I implement SQL query in order to select all employees sorted by last name in ascending order in the following Java class: Answer If there is a separate column for last name then it is very much easy to achieve. If there is only one column i.e. full name , then split the string from the last white

Advertisement