How to stop a Postgres script when it encounters an error?

I think the solution to add following to .psqlrc is far from perfection \set ON_ERROR_STOP on there exists much more simple and convenient way – use psql with parameter: psql -v ON_ERROR_STOP=1 better to use also -X parameter turning off .psqlrc file usage. Works perfectly for me p.s. the solution found in great post from … Read more

MySQL columns with DEFAULT NULL – stylistic choice, or is it?

As documented under Data Type Default Values: If the column can take NULL as a value, the column is defined with an explicit DEFAULT NULL clause. (I think they meant implicit, not explicit). Moreover, as documented under CREATE TABLE Syntax: If neither NULL nor NOT NULL is specified, the column is treated as though NULL … Read more

How to run SQL scripts and get data on application startup?

By default, Spring-Boot loads data.sql and/or data-${platform}.sql. However, keep in mind that the script would be loaded at every start, so I would think it makes more sense (at least for production), to just have the values already present in the database, not re-inserted at every start. I’ve personally only used database initialization for test/dev … Read more

How to Execute SQL Script File in Java?

There is great way of executing SQL scripts from Java without reading them yourself as long as you don’t mind having a dependency on Ant. In my opinion such a dependency is very well justified in your case. Here is sample code, where SQLExec class lives in ant.jar: private void executeSql(String sqlFilePath) { final class … Read more

How can I describe a table in Oracle without using the DESCRIBE command?

You’re looking for USER_TAB_COLUMNS – all the columns, and their descriptions in the schema the query is executed in – or ALL_TAB_COLUMNS – the same except for all tables that user has permission to view. A typical query might be: select * from user_tab_columns where table_name=”MY_TABLE” order by column_id column_id is the “order” of the … Read more

Executing script file in h2 database

You can use the RUNSCRIPT SQL statement: RUNSCRIPT FROM ‘test.sql’ or you can use the RunScript standalone / command line tool: java -cp h2*.jar org.h2.tools.RunScript -url jdbc:h2:~/test -script test.sql You can also use the RunScript tool within an application: RunScript.execute(conn, new FileReader(“test.sql”));

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)