我在postgres数据库中使用下面的select语句,并收到错误消息“ timetstamp类型的输入语法无效:” Wed Sep 04 08:45:15 GST 2019”
select * from testtable where created_time >= 'Wed Sep 04 08:45:15 GST 2019"
此处错误报告与我的时区“ GST”有关。
如果我将GST更改为GMT,则查询工作正常。
请注意,我的“ Postgresql.conf”文件中的时区为“ timezone ='Asia / Muscat”。
请告知。
答案 0 :(得分:0)
我不确定private static final String HOST = "my-key";
private static final String MASTER_KEY = "master-key";
private static final String DATABASE_ID = "TablesDB";
private static DocumentClient documentClient = new
DocumentClient(HOST, MASTER_KEY,
ConnectionPolicy.GetDefault(), ConsistencyLevel.Session);
public static void main(String[] args) {
try {
DocumentClient documentClient = getDocumentClient();
String queryString = "SELECT * FROM root r r.id='" + DATABASE_ID+ "'";
FeedResponse feedResponse = documentClient.queryDatabases(queryString, null);
if(feedResponse != null){
List<Database> databaseList = feedResponse.getQueryIterable().toList();
System.out.println("At 19 line");
Database databaseCache = new Database();
if (databaseList.size() > 0) {
databaseCache = databaseList.get(0);
} else {
Database databaseDefinition = new Database();
databaseDefinition.setId(DATABASE_ID);
databaseCache = documentClient.createDatabase(databaseDefinition, null).getResource();
}
}else{
System.out.println("feedResponse is null");
}
} catch (DocumentClientException e) {
e.printStackTrace();
}
}
private static DocumentClient getDocumentClient() {
return documentClient;
}
是否为可用时区-您可以从GST
视图中找到可用时区的列表
https://www.postgresql.org/docs/current/view-pg-timezone-names.html
要检查是否存在GST,请尝试:
pg_timezone_names
否则,请从该列表中选择一个。