Showing posts with label postgresql. Show all posts
Showing posts with label postgresql. Show all posts

Friday, January 01, 2016

JPA : Can not run ddl-auto=update with Spring Boot

Caused by: org.postgresql.util.PSQLException: ERROR: column i.indproc does not exist


This may happen while trying to update development db schema without loosing data and adding schema updates into development db:


  1. spring.jpa.hibernate.ddl-auto=update

Problem is with Postgresql JDBC driver 9.1-901-1.jdbc4:

  1. compile group: 'postgresql', name: 'postgresql', version: '9.1-901-1.jdbc4'
Upgrade it to latest version 42.2.5 in build.gradle:

  1. compile group: 'org.postgresql', name: 'postgresql', version: '42.2.5'
Maven repository:
https://mvnrepository.com/artifact/org.postgresql/postgresql/42.2.5

maven:
<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.2.5</version>
</dependency>

Sunday, July 05, 2015

postgresql : sql to select all distinct characters from column data

select * from company:

 id | market | symbol | crawl_date
----+--------+---------+------------
  1 | ss         | dd       | 2014-10-21
  2 | ss         | ss        | 2014-10-21
  3 | ss1       | ds        | 2014-10-21
  4 | ss1       | sd1      | 2014-10-21
  5 | ss1       | dd1     | 2014-10-21
  6 | ss1       | ss1      | 2014-10-22
  7 | ss1       | d11     | 2014-10-22

Get all distinct characters in column company.symbol:



  1. select string_agg(c,'')
  2. from (
  3. select distinct regexp_split_to_table(symbol,'') as c
  4. from company
  5. ) t;

Output:

 string_agg 
------------
 1ds
(1 row)

Sunday, May 04, 2014

Spring 3 Hibernate 4 Annotations Entity Manager PostgreSQL maven standalone example

Create the sample postgresql database at first in PgAdmin :
  1. CREATE DATABASE "TESTS"
  2. WITH OWNER = postgres
  3. ENCODING = 'UTF8'
  4. TABLESPACE = pg_default
  5. CONNECTION LIMIT = -1;

Then create the table in databse 'TESTS':
  1. CREATE TABLE USERS (
  2. ID serial NOT NULL,
  3. USERNAME text NOT NULL,
  4. NAME text NOT NULL
  5. );

Download the example from github.Build(mvn clean install) And run Main.java