Im using Postgres 9.3, I get the Java database driver like this
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException e) {
System.err.println("Couldn't load org.postgresql.Driver");
System.exit(1);
}
Then I do :
Array urlData = rs.getArray("urls");
String[] urls = (String[]) urlData.getArray();
but last line is failing with NullPointerException because urlData is null
Why is this, is Array not supported for Postgresql, the tutorial does state not supported for Mysql
https://docs.oracle.com/javase/tutorial/jdbc/basics/array.html
Or it is just null because no data for urls for a particular row?
The attempt to use getObject suggested in answer failed with
Exception in thread "main" java.lang.AbstractMethodError: Method org/postgresql/jdbc4/Jdbc4ResultSet.getObject(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object; is abstract
at org.postgresql.jdbc4.Jdbc4ResultSet.getObject(Jdbc4ResultSet.java)
at com.jthink.jthinksearch.index.indexer.discogs.ArtistIndex.documentFromResultSet(ArtistIndex.java:209)
at com.jthink.jthinksearch.index.indexer.discogs.ArtistIndex.indexData(ArtistIndex.java:176)
at com.jthink.jthinksearch.index.indexer.IndexBuilder.buildDatabaseIndex(IndexBuilder.java:226)
at com.jthink.jthinksearch.index.indexer.IndexBuilder.buildIndex(IndexBuilder.java:151)
at com.jthink.jthinksearch.index.indexer.IndexBuilder.main(IndexBuilder.java:119)
AbstractMethodErrorsuggests you are using an old version of the driver (thegetObjectmethod you tried was introduced in Java 7 / JDBC 4.1), consider upgrading to a newer version of the PostgreSQL JDBC driver.String[] urls = rs.getObject("urls", String[].class);I get an errorThe org.postgresql.jdbc4.Jdbc4ResultSet.getObject (int, Class <T>) function is not yet implemented.I'm using mvnrepository.com/artifact/postgresql/postgresql/… do you have any idea why this error please? I rolledback my solution you can check where it was my mistake maybeorg.postgresql.util.PSQLException: conversion to class [Ljava.lang.String; from 2 003 not supported