Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 14 total
Thread Connection String Support
Fri, Nov 15 2024 10:26 PMPermanent Link

Shane Sturgeon

Hi

I'm using the VCL edition of EDB, and am evaluating the HTML Reporting Library. In the process of creating an adaptor for the HRL (it doesn't come with an EDB one out of the box) I am using a FireDAC example which makes use of a Connection string passed into the adaptor as a set of TParams.

I googled on this, and found mention of EDB Connection strings in relation to the PHP edition, and from searches here it seems the ODBC version may also use them, but the VCL help file is silent on the matter.

Does anyone know if Connection Strings are supported for the VCL edition, and if so, how to implement them?

Cheers
Shane
Mon, Nov 18 2024 3:15 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Shane Sturgeon wrote:

> Hi
>
> I'm using the VCL edition of EDB, and am evaluating the HTML
> Reporting Library. In the process of creating an adaptor for the HRL
> (it doesn't come with an EDB one out of the box) I am using a FireDAC
> example which makes use of a Connection string passed into the
> adaptor as a set of TParams.
>
> I googled on this, and found mention of EDB Connection strings in
> relation to the PHP edition, and from searches here it seems the ODBC
> version may also use them, but the VCL help file is silent on the
> matter.
>
> Does anyone know if Connection Strings are supported for the VCL
> edition, and if so, how to implement them?
>
> Cheers
> Shane

Hi Shane,

is this HTML Reporting Library from Alexander (delphihtmlcomponents)?
If so, we have this in use with normal edb components.

To use this, you need to create your own DatabaseAdapter based on
thtSQLAdapter with only few functionalities.
Tue, Nov 19 2024 11:44 AMPermanent Link

Heiko Knuettel

I think connection strings are an ODBC thing.

You don't need them in VCL since you have the EDB components that handle the connection.
Wed, Dec 4 2024 6:52 PMPermanent Link

Shane Sturgeon

Hi Yusuf

>> is this HTML Reporting Library from Alexander (delphihtmlcomponents)?
Yes

>>If so, we have this in use with normal edb components.
>> To use this, you need to create your own DatabaseAdapter based on
>> thtSQLAdapter with only few functionalities.

I've created an adaptor by injecting a TEDBDatabase into the constructor, and then creating a TEDBQuery using properties from that DB in the CreateDataset method. It works, but it does mean I need to pass in a database component when creating the adaptor. I was thinking that I could remove that coupling by passing in a connection string instead, and just create the component internally.

How have you implemented your adaptor? Does it need a database passed in or does it take string parameters and create all that's needed internally?
Thu, Dec 5 2024 3:42 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Shane Sturgeon wrote:

> Hi Yusuf
>
> >> is this HTML Reporting Library from Alexander
> (delphihtmlcomponents)?  Yes
>
> > > If so, we have this in use with normal edb components.
> >> To use this, you need to create your own DatabaseAdapter based on
> >> thtSQLAdapter with only few functionalities.
>
> I've created an adaptor by injecting a TEDBDatabase into the
> constructor, and then creating a TEDBQuery using properties from that
> DB in the CreateDataset method. It works, but it does mean I need to
> pass in a database component when creating the adaptor. I was
> thinking that I could remove that coupling by passing in a connection
> string instead, and just create the component internally.
>
> How have you implemented your adaptor? Does it need a database passed
> in or does it take string parameters and create all that's needed
> internally?

Hi Shane,

I pass a Database to the adaptor but in the adaptor I create a new
Database-Component based on the base-database. This makes everything
thread-safe
Thu, Dec 5 2024 9:15 PMPermanent Link

Shane Sturgeon

"Yusuf Zorlu" wrote:

> I pass a Database to the adaptor but in the adaptor I create a new
> Database-Component based on the base-database. This makes everything
> thread-safe

Hi Yusuf - would you mind sharing your code? I'm wanting to make sure my implementation is thread safe, but I'm very new to multi-threading, so am not confident in my ability to get something that crucial right based on a description. For example, wouldn't a new session also be required?
Fri, Dec 6 2024 1:43 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Shane Sturgeon wrote:

> "Yusuf Zorlu" wrote:
>
> > I pass a Database to the adaptor but in the adaptor I create a new
> > Database-Component based on the base-database. This makes everything
> > thread-safe
>
> Hi Yusuf - would you mind sharing your code? I'm wanting to make sure
> my implementation is thread safe, but I'm very new to
> multi-threading, so am not confident in my ability to get something
> that crucial right based on a description. For example, wouldn't a
> new session also be required?

Hi Shane,

I'd be happy to share my approach, but we don't work directly with EDB
components. Instead, we've developed a custom connection component that
encapsulates both the EDB session and the EDB database into a single
component.

Here's the general idea:
1. Pass your database connection to the adapter.
2. The adapter creates a private fConnection.
3. It then assigns all connection parameters from the base connection.
That's it!

One important note when working with EDB components: ensure that each
connection/session is used within a single thread only. This is crucial
to avoid threading issues.
Fri, Dec 6 2024 5:39 PMPermanent Link

Shane Sturgeon

Hi Yusuf

Thanks for elaborating.

I'm not sure what you mean in #1 by "connection"? Is that what EDB refers to as a Session?

This is my interpretation of what you have said.
You have a class, and in that class you create and store in fields both an EDBSession and an EDBDatabase. These will be what you eventually use to create the HTML Library Adaptor (a second class), or is the HRL Adaptor the class that you create the Session and Database in (i.e. it's all in one class)?

I'm assuming you use an Autosession name? to make it threadsafe?

Do you pass in the tablename and config parameters (user, Pass, Path to config file etc) as strings?

Cheers
Shane


"Yusuf Zorlu" wrote:

Shane Sturgeon wrote:

> "Yusuf Zorlu" wrote:
>
> > I pass a Database to the adaptor but in the adaptor I create a new
> > Database-Component based on the base-database. This makes everything
> > thread-safe
>
> Hi Yusuf - would you mind sharing your code? I'm wanting to make sure
> my implementation is thread safe, but I'm very new to
> multi-threading, so am not confident in my ability to get something
> that crucial right based on a description. For example, wouldn't a
> new session also be required?

Hi Shane,

I'd be happy to share my approach, but we don't work directly with EDB
components. Instead, we've developed a custom connection component that
encapsulates both the EDB session and the EDB database into a single
component.

Here's the general idea:
1. Pass your database connection to the adapter.
2. The adapter creates a private fConnection.
3. It then assigns all connection parameters from the base connection.
That's it!

One important note when working with EDB components: ensure that each
connection/session is used within a single thread only. This is crucial
to avoid threading issues.
Mon, Dec 9 2024 2:00 AMPermanent Link

Yusuf Zorlu

MicrotronX - Speditionssoftware vom Profi

Shane Sturgeon wrote:

> Hi Yusuf
>
> Thanks for elaborating.
>
> I'm not sure what you mean in #1 by "connection"? Is that what EDB
> refers to as a Session?
>
> This is my interpretation of what you have said.
> You have a class, and in that class you create and store in fields
> both an EDBSession and an EDBDatabase. These will be what you
> eventually use to create the HTML Library Adaptor (a second class),
> or is the HRL Adaptor the class that you create the Session and
> Database in (i.e. it's all in one class)?
>
> I'm assuming you use an Autosession name? to make it threadsafe?
>
> Do you pass in the tablename and config parameters (user, Pass, Path
> to config file etc) as strings?
>
> Cheers
> Shane
>
>
> "Yusuf Zorlu" wrote:
>
> Shane Sturgeon wrote:
>
> > "Yusuf Zorlu" wrote:
> >
> > > I pass a Database to the adaptor but in the adaptor I create a new
> > > Database-Component based on the base-database. This makes
> > > everything thread-safe
> >
> > Hi Yusuf - would you mind sharing your code? I'm wanting to make
> > sure my implementation is thread safe, but I'm very new to
> > multi-threading, so am not confident in my ability to get something
> > that crucial right based on a description. For example, wouldn't a
> > new session also be required?
>
> Hi Shane,
>
> I'd be happy to share my approach, but we don't work directly with EDB
> components. Instead, we've developed a custom connection component
> that encapsulates both the EDB session and the EDB database into a
> single component.
>
> Here's the general idea:
> 1. Pass your database connection to the adapter.
> 2. The adapter creates a private fConnection.
> 3. It then assigns all connection parameters from the base connection.
> That's it!
>
> One important note when working with EDB components: ensure that each
> connection/session is used within a single thread only. This is
> crucial to avoid threading issues.

Hi Shane,

here's a code snippet where you can see, how we create the Dataadapter:

---- snip ----
function ts_mxrunreport_ex1(const Report: string; const Params:
tarray<string>): string;
var
   R: THtReportDocument;
   vmyCONN:iConnection;
   vSQLAdapter:THtmxDatabaseAdapter;
begin
   try
      try
         vmyCONN:=dm.rootdb.GetDatabaseConnectionfromPool();
         vSQLAdapter:=THtmxDatabaseAdapter.Create(vmyCONN.Connection, False);
         try
            R := THtReportDocument.CreatefromString(Report);
            R.SQLAdapter:=vSqladapter;

            // add params ...

            Result := R.Render;
         finally
            R.Free;
         end;
      finally
         if assigned(vsqladapter) then freeandnil(vsqladapter);
         vmyCONN:=nil;
      end;
   except
      on e:Exception do begin
         messagedlg('mxrunreport:
'+e.message+#13+#13+'Report-Code:'+#13+report, mterror, [mbok],0);
      end;
   end;
end;
Mon, Dec 9 2024 4:08 PMPermanent Link

Shane Sturgeon

Thanks Yusuf

I think I have a sense of what you are doing now. The iConnection interface is what was missing in my understanding. I take it that has database and session properties or do you just ask it for an EDBQuery instance, and leave the setup of that to the 'black box' of the interface?

Cheers
Shane
Page 1 of 2Next Page »
Jump to Page:  1 2
Image