postgresql-9.2

unresolved dependency for postgresql 9.2 jar in play framework

让人想犯罪 __ 提交于 2019-12-05 02:29:42
I am using postgresql 9.2 with play framework 2.1 I downloaded the driver here: http://jdbc.postgresql.org/download.html (JDBC4 Postgresql Driver, Version 9.2-1002) My project/Build.scala file is as follows: import sbt._ import Keys._ import play.Project._ object ApplicationBuild extends Build { val appName = "myApp" val appVersion = "0.1" val appDependencies = Seq( "postgresql" % "postgresql" % "9.2-1002.jdbc4") val main = play.Project(appName, appVersion, appDependencies) } I have placed the jdbc driver in the following locations in the play directory structure: myApp/lib/postgresql-9.2-1002

PostgreSQL - properly change ID of table row

落花浮王杯 提交于 2019-12-05 02:02:46
How to change id of some table's row? Like: UPDATE table SET id=10 WHERE id=5; But in way that it would cascade changes to every other table that references this table with that id? I want to do this, because I need to import data from another database which has most of the same tables, but ids are different. So if ids would match old database, it would be easier to import data correctly. Suppose you have these two tables: create table referenced (id integer primary key); create table referencer (a integer references referenced (id)); Table referencer references table referenced: => \d

Postgres nested JSON array using row_to_json

两盒软妹~` 提交于 2019-12-04 18:30:32
问题 I am trying to create nested json array using 2 tables. I have 2 tables journal and journaldetail. Schema is - journal : journalid, totalamount journaldetail : journaldetailid, journalidfk, account, amount Relation between journal and journaldetail is one-to-many. I want the output in following format : { journalid : 1, totalamount : 1000, journaldetails : [ { journaldetailid : j1, account : "abc", amount : 500 }, { journaldetailid : j2, account : "def", amount : 500 } ]} However, by writing

Test script for transaction concurrency for postgresql

泪湿孤枕 提交于 2019-12-04 17:17:39
I would like to test some variants of transaction concurrency in PostgreSQL and for that I need a script which would force two transaction to start at exactly the same time. Something that does not requires manual intervention ;) Any ideas? Craig Ringer You can homebrew this by taking a LOCK on a table, setting up your transactions, then releasing the lock by rolling back the transaction that got the lock. See this prior answer and its links for details on this approach. While I demonstrated it using three psql sessions it's equally viable to do it with bash co-processes, a Python script using

Problems with a PostgreSQL upsert query

喜你入骨 提交于 2019-12-04 14:33:15
I'm trying to update the database by either updating or inserting a new record into the vote_user_table . The table is defined as follows: Column | Type | Modifiers -----------+---------+-------------------------------------------------------------- id | integer | not null default nextval('vote_user_table_id_seq'::regclass) review_id | integer | not null user_id | integer | not null positive | boolean | default false negative | boolean | default false Indexes: "vote_user_table_pkey" PRIMARY KEY, btree (id) Here's the query I'm using. I'm actually using parameters for all of the values, but for

How to find first free time in reservations table in PostgreSql

∥☆過路亽.° 提交于 2019-12-04 13:04:06
Reservation table contains reservations start dates, start hours and durations. Start hour is by half hour increments in working hours 8:00 .. 18:00 in work days. Duration is also by half hour increments in day. CREATE TABLE reservation ( startdate date not null, -- start date starthour numeric(4,1) not null , -- start hour 8 8.5 9 9.5 .. 16.5 17 17.5 duration Numeric(3,1) not null, -- duration by hours 0.5 1 1.5 .. 9 9.5 10 primary key (startdate, starthour) ); table structure can changed if required. How to find first free half hour in table which is not reserved ? E.q if table contains

Create index on json field in PostgreSQL 9.2

本秂侑毒 提交于 2019-12-04 12:42:21
I have a few tables with json columns and would like to build an index on these columns. However, I get a default operator class ( http://www.postgresql.org/docs/9.2/static/sql-createopclass.html ). Has someone already done that or give me an alternative? To reproduce the problem, try: >> create table foo (json json, id int); CREATE TABLE >> create index on foo (id); CREATE INDEX >> create index on foo (json); ERROR: data type json has no default operator class for access method "btree" HINT: You must specify an operator class for the index or define a default operator class for the data type.

PostgreSQL “initdb” (Database Initialization) on Linux

半城伤御伤魂 提交于 2019-12-04 10:36:47
I'm working on creating a Database Cluster (single database) in PostgreSQL 9.x working on a Linux system (CentOS - RedHat - Fedora). I've installed the correct PostgreSQL packages (server & client) however, I'm unable to create a database and get some type of initializing dependencies error: Bus Error / Exit Code 135 . I've changed my user to "postgres" with "su postgres" and then tried to initialize the database with "initdb" (this may be the problem) Installed: postgresql-libs-9.2.13-1.el7_1.x86_64 Installed: postgresql-9.2.13-1.el7_1.x86_64 Installed: postgresql-server-9.2.13-1.el7_1.x86_64

Postgres Query JSON Array that contains something

大兔子大兔子 提交于 2019-12-04 09:16:30
Postgres has this JSON datatype and I am wondering how can I query data inside a JSON array ? I am using Postgres 9.3.1 I have inserted into PUBLISHER table that has these 2 fields name: string and data: json INSERT INTO PUBLISHER (name, data) VALUES ('PUB1', [{"code":"PA1","author":"James","type":"Novel"},{"code":"PA2","author":"John","type":"Science"}] INSERT INTO PUBLISHER (name, data) VALUES ('PUB2', [{"code":"PA1","author":"Dickens","type":"Novel"},{"code":"PA2","author":"Tom","type":"Comic"}] I want to do a query and list out authors with the type "Novel". In this case it would be "James

Can't log into system user postgres

亡梦爱人 提交于 2019-12-04 08:01:21
问题 I installed postgresql on mac using brew. I wasn't asked about for the password for postgresql during the installation. Now I need to create a user and can't: Alexs-MacBook-Air:mydir alex$ su - postgres Password: su: Sorry Whatever password (including empty) I use, it is wrong. What's the easiest way to reset it? 回答1: You're trying to access the system user named postgres . According to comments you left on the other answers, there is no such user. You can't change the password of a user that