Page 1 of 1

Edit Postgres Connection String

Posted: Wed May 25, 2016 5:55 pm
by smartleopard
Hi,
I have a report that it's connection is set to my localhost Postgres. Now I want to change it's connection to my databse server with Java code. I used the code below to do that before loading report in JAVA.FX designer.

Code: Select all

StiJDBCDatabase stiJDBCDatabase = (StiJDBCDatabase) stiReport.getDictionary().getDatabases().get(0);
stiJDBCDatabase.setConnectionString(My Connection String);
stiJDBCDatabase.setUser("username");
stiJDBCDatabase.setPassword("password");
But when i go to preview tab, exception happens. The exception is about connection string. It fails to authenticate because it yet tries to connect to localhost. It shows:

Code: Select all

connectionString=url=jdbc:postgresql://145.154.51.29:5432;database=mydb;user=username;password=password, promptUserNameAndPassword=false,
url=jdbc:postgres://localhost:5432/mydb,
user=username,
password=password,
driver=org.postgresql.Driver,
other={url=jdbc:postgresql://145.154.51.29:5432}
As you can see the connectionString shows my database server ip, but the url still shows the localhost.

The connection string I used in designer when i first created the report is:

Server=localhost;Port=5432;Userid=postgres;Password=postgres;Database=mydb

I'm using JAVA.FX 2014.3. Thx for your help.

Re: Edit Postgres Connection String

Posted: Thu May 26, 2016 6:30 am
by Vadim
Hello.
Your version is very old, it's impossible to find problem now.
So if your old connections string is: Server=localhost;Port=5432;Userid=postgres;Password=postgres;Database=mydb
you should change it to: Server=145.154.51.29;Port=5432;Userid=postgres;Password=postgres;Database=mydb

Re: Edit Postgres Connection String

Posted: Thu May 26, 2016 8:28 am
by smartleopard
Hi,
I tried the JAVA.FX 2016.1 too. There is also the same problem. My requirement force me to change connection string with Java code. I used the below code to fetch current database in report and change it's connection string:

Code: Select all

StiJDBCDatabase stiJDBCDatabase = (StiJDBCDatabase) stiReport.getDictionary().getDatabases().get(0);
stiJDBCDatabase.setConnectionString("My New Connection String");
stiJDBCDatabase.setUser("username");
stiJDBCDatabase.setPassword("password");
As I know, in setConnectionString method you set url too. But the set url is not correct because when I call toString method of StiJDBCDatabase, it shows:

connectionString=url=jdbc:postgresql://145.154.51.29:5432;database=mydb;user=username;password=password, promptUserNameAndPassword=false,
url=jdbc:postgres://localhost:5432/mydb,
user=username,
password=password,
driver=org.postgresql.Driver,
other={url=jdbc:postgresql://145.154.51.29:5432}

As you can see, the url still refers to localhost, but connection string refers to new connection string I set and the connect method of StiJDBCDatabase class uses url to connecto to DB.

Thanks for your attention.

Re: Edit Postgres Connection String

Posted: Thu May 26, 2016 9:12 am
by Alex K.
Hello,

Can you please send us a request on support@stimulsoft.com.

Thank you.

Re: Edit Postgres Connection String

Posted: Thu May 26, 2016 9:49 am
by smartleopard
Aleksey wrote:Hello,

Can you please send us a request on support@stimulsoft.com.

Thank you.
Hi,

Ok, I did

Thanks

Re: Edit Postgres Connection String

Posted: Thu May 26, 2016 10:54 am
by Alex K.
Hello,

Ok. We will let you answer on our support system.