how to connect UNC-located database to embedded server? - delphi

I have next specific situation. I have an application using Firebird embedded server. The files: application executive, database, fbembed.dll are located in the same folder. Everything is good and working good.
Now my client says so:
I would like to place all your application file on a server and run it via local network from all workstations.
So as I see I start application on the server and it starts. But database connection string looks now like:
//SERVER/share/db.fdb
Yes, I know conventions about allowed firebird paths from here: FAQ: What's a connection string?
I do not understand what should I use with embedded server? Is it possible at all?

If you want to access a Firebird database over the network, then you need to install Firebird server and connect through the server. You can't (at least not by default) access a database from a network path, and you really shouldn't (although there is a config option to allow it), as it can lead to database corruption due to insufficient or incorrect filelocking support over the network.
So: Don't use Firebird embedded, but install Firebird server and configure the clients to connect to Firebird server.

Related

Delphi XE2 with Zeoslib and Oracle Connection

Can anyone help me in setting up ZeosLib 7.1.4a to connect to Oracle 11g Release 2 Standard database.
Currently we are using Delphi XE2, oracle is installed and the tnsnames.ora file specifies the connections to our different servers and databases, and it is also set up within BDE.
We need to move away from BDE components as they are no longer available with Delphi XE3 and upwards. We use Direct Oracle Access components, but that is a paid 3rd party software, that is why we want to move over to ZeosLib.
What settings need to be set on the ZConnection component in order for it to connect to the oracle database, as there is a Database parameter and LibraryLocation parameter that are looking for actual files, and then there is the HostName parameter?
I never used Oracle, but I don't think it should be too different from Firebird, MySQL, SQL Server and others I've tried on Zeos.
The properties you need to set are:
Protocol = oracle;
HostName = your database server ip is probably your best bet; maybe you don't need this for oracle due to tnsnames... try leaving it empty
Database = your database name. This could be a filename (in the server) or a database alias;
User = User name to connect to the database;
Password = well, the password...
LibraryLocation is the location of the client-side library (a dll) to use for the connection. Normally you don't need to set this property if your library is installed to your system folder or comes along with your executable.
You may also need to set the Port if it's not the default one.

connecting to a grails app database

I am a python developer by day, but I have some java experience as well (mostly with struts). At work I was handed a grails app to install, which was ok, but the owners of the app didn't supply any credentials, and the app loads to a login page.
I unpacked the war, but I think the DB config has been packaged into a jar somewhere, because I can't seem to find any connection URL. There's an h2 db file that's been created after I deployed the App, so I'm wondering:
how can I connect to the db like you normally would with SQLite or mysql client, browse tables, and create an admin user so I can login?
Go with decompilation. You need not only a user and password, but at least a database JDBC URL. That may include DBMS name, host, port, database name - depending on Java driver specifics. Then connect as you would normally in Python or whatever, or with DBVisualizer.
But if the database is in H2/hsql (URL is like jdbc:h2:mem:XXX), you've got a problem: it is a Java in-process DBMS. In order to gain external access to it, you'll need to change the decompiled code, compile and pack it back with some additions. Hope it's not your case.
Another way in hsql/H2 case is to find and decompile database bootstrap code - as it's an in-process DB, it should be filled at every application startup, so there should be a code creating that superuser.
In Grails, the DB configuration, including authentication settings, are declared in a file called Datasource.groovy which is then compiled into the WAR. You'll need the source code to find the username and password for the H2 DB.
I don't know if Python can connect to a java datasource but it may be a solution.
An other solution may be to provide some REST webservice from Grails side to make it possible for the python program to access the database. This is the way I prefer and I often choose.
By the way, you have the configuration of the databases used by Grails in the conf directory (grails-app/conf/DataSource.groovy) and you'll get the jdbc URL to the database which could be convert to a classical URL. For example : jdbc:mysql://localhost/my_app refers to the database my_app on localhost and default port for a mysql database.
Feel free to ask if you need more information.
Cheers

Migrating .NET Database to Shared Hosting

Built an app locally with an EF code-first database - not sure how to upload it to a shared hosting environment such as GoDaddy. It makes sense that something would be amiss because on the shared hosting your code can't just go create a database, but on the flip side I can't find anything to copy the CREATE sql and create it on the server like you would with MySQL
Feel a little silly because I've been using .NET for over a year now but at work the databases are already set up and we have full control over our environments.
If the database has no data that you need to preserve the easiest method is just to install the app on the new host and set the connection string to your new database on the host. On the first attempt to load a page accessing the database, the database will automatically be created (note that you need to load a page which hits the database - sometimes the home page is not sufficient).
This method is a lot more straightforward than generating SQL and then executing it on the production database.
If there is data that you need to preserve then the best method will be taking a backup and installing the backup on the host. In SSMS simply right-click the database in the left pane, then Tools > Backup... To restore on the server connect to the server in SSMS and right-click the 'Database' node in the left panel and select 'Restore Database...' I'm not sure if the host provides a direct connection from SSMS but they should at a minimum have a mechanism to restore a .bak file.
Going forward you should ensure that you can execute SQL on your database as a very convenient method for deploying EF Migrations is to generate the SQL update script on the development server and then deploy this by executing it in production.
Depending on your web host, you may be able to restore the database. If this is an option, simply back up your database on your local machine and restore it on the server via the management console.
You can back up your local database using SQL Server Management Console. This works well even for larger databases as you can directly restore all your data, your schema, etc.
I've had experience with three different hosts so far and all of them have this as an option. You'll usually find this under the Database tab for the web site. The rest from there is up to you because it's usually different across the various hosts.

SQL Server 2008 OLE DB CONNECTION FAILS FROM OUTSIDE

I have a working SQL Server 2008 R2 Express installed on a Windows 2008 server on a cloud machine. All type of connections (ado.net, nhibernate etc.) from several client applications works fine except the OLEDB one. SQL Native Client also works fine.
When I tried to connect from the server locally and as a data source write the instance name, everything was OK. But from outside, I had the problem or also if I write wan ip or dns I had the problem also from local.
-- works perfect from everywhere
Provider=SQLNCLI10;Data Source=mntek.no-ip.org;User ID=xxx;Password=xxx;
-- does not work from anywhere
Provider=SQLOLEDB.1;Data Source=mntek.no-ip.org;User ID=xxx;Password=xxx;
-- works only from local
Provider=SQLOLEDB.1;Data Source=flz001\sqlexpress;User ID=xxx;Password=xxx;
Error: [DBNETLIB][ConnectionOpen (Invalid Instance()).Invalid
connection.
-- works perfect with ado.net
Data Source=mntek.no-ip.org;User ID=xxx;Password=xxx
Some other client applications (not mine) was written with oledb connection so I need them to connect the db with oledb provider.
Any ideas?
Regards,
Mert
It has been a while since this was asked, but I am currently working through an issue related to OLE DB and SQL Server that sounds possibly related.
I found that, even though the server was using the default port (1433), I still had to explicitly specify it in the UDL connection string like this:
Provider=SQLOLEDB.1;User ID=USER;Data Source=IP,1433
I've asked why that might be necessary here:
Why might SQL Server 2008 OLE DB UDL require port 1433 explicitly specified?
Maybe try that and see if it helps.

Firebird aliases

I have developed an application using Delphi and Firebird 1.5, where the server is located on the same machine as the application. I am now deploying the application to another site, where the Firebird server (Superserver) is running on one machine (NT4) whilst the client is running on another machine.
The application can connect to the database if I include the qualified path in the application (t:\db\cinema.gdb), but naturally I would prefer to use an alias, so that the same code will work on my development machine (with the local server).
So, two questions:
Where should the 'aliases.conf' file exist - on each machine along with the application, or on the server?
What should the alias be? cinema = t:\db\cinema.gdb, assuming that the database is on a mapped drive t? cinema = 192.168.2.121:f:firebird\db\cinema.gdb, using the IP address of the server and the path to the database as the server sees it?
The alias file only exists on the server!
The alias maps directly to the file, e.g. cinema = c:\firebird\db\cinema.fdb. Don't use a mapped drive, this decreases performance. The client connects with database name servername:alias.
The aliases.conf should be on the server only.
And you should always use the full address, with the IP and the full path to the database on the server. Since drive mappings may change (and they always do when you least expect it) it is seldom a good idea to use them as a reference to files or databases that should be in a fixed location.
Personally I do not use aliases at all in my C++Builder / Firebird application but just set up the full path in the programs ini file or as a registry entry (on the client side of course). The ini-file is there anyway and I do not create another dependency on the aliases.conf file.

Resources