Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get PostgreSQL range types via jdbc

Is there right way to get range types?

Or parse as String, and wait for native support...

For example tsrange:

["2010-01-01 14:00:00","2010-01-01 15:00:00"]

PG Range tupes - http://www.postgresql.org/docs/devel/static/rangetypes.html

like image 523
r00tGER Avatar asked Dec 17 '14 11:12

r00tGER


People also ask

Does JDBC work with PostgreSQL?

To connect to the PostgreSQL database server from a Java program, you need to have PostgreSQL JDBC driver. You can download the latest version of the driver on the postgresql.org website via the download page.

What is range in PostgreSQL?

Range types are a unique feature of PostgreSQL, managing two dimensions of data in a single column, and allowing advanced processing. The main example is the daterange data type, which stores as a single value a lower and an upper bound of the range as a single value.


1 Answers

You can use range functions in your query to create individual date columns.

select lower(some_range) as start, upper(some_range) as end ...

Then you can use ResultSet's getDate() method on the resulting columns.

like image 151
Seth Avatar answered Oct 10 '22 07:10

Seth