Edit Postgres Connection String

Stimulsoft Reports.JAVA discussion
Post Reply
smartleopard
Posts: 22
Joined: Wed Apr 01, 2015 2:29 pm

Edit Postgres Connection String

Post 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.
Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: Edit Postgres Connection String

Post 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
smartleopard
Posts: 22
Joined: Wed Apr 01, 2015 2:29 pm

Re: Edit Postgres Connection String

Post 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.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Edit Postgres Connection String

Post by Alex K. »

Hello,

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

Thank you.
smartleopard
Posts: 22
Joined: Wed Apr 01, 2015 2:29 pm

Re: Edit Postgres Connection String

Post by smartleopard »

Aleksey wrote:Hello,

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

Thank you.
Hi,

Ok, I did

Thanks
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Edit Postgres Connection String

Post by Alex K. »

Hello,

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