Firebird aliases - delphi

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.

Related

browsing distinct Neo4j databases in the same machine

I am experimenting with several Neo4j databases in my machine. The databases have been generated and populated from Java programs.
Now I would like to inspect them.
It seems that the recommended way is to open the web console so it points to a specific database by means of configuring the property:
org.neo4j.server.database.location=<database location path>
in the neo4j configuration file: conf/neo4j-server.properties
This if fine if I am only interested in one database. But it does not look like a good idea if I am switching often between databases or if I want to explore more than one at the same time.
Is it possible to configure distinct web consoles (maybe using distinct ports) so they refer to my distinct databases?
And is it possible to do this without installing several instances (binaries) of Neo4j in my machine and having to modify lots of configuration files?
Yes! If you edit that same conf/neo4j-server.properties file you can change the org.neo4j.server.webserver.port and org.neo4j.server.webserver.https.port values (I normally set the https port to one less than the http port).
Once you've done that you run ./bin/neo4j start (make sure you shut down your Java app which is accessing the database first) to start the server on that port and then simply visit http://localhost:<port>
I'm not 100% sure if generating the database from Java will generate everything that you need for running a server. If not you can download Neo4j from http://neo4j.com/download/, make multiple copies of it, and replace the graph.db folder with yours one (make sure you shut down any processes which are accessing those databases before copying the directory). Also if you've downloaded a newer version you might need to set allow_store_upgrade=true (see: http://neo4j.com/docs/stable/deployment-upgrading.html)
You can have multiple Embedded Neo4j databases without installing separate binaries. You just need to be configure the different database path for each instance of the database.

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.

how to connect UNC-located database to embedded server?

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.

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

MVC 3 Adding a local Database

I am currently going through the MvcMusicSore tutorial (MVC 3). I have full sql server 2008 installed and created a local database by running the SqL scripts included in the MvcMusicStore-Assets data folder. However when trying to add the mdf to the AppFolder in Visual Studio 2010 I get the error Access Denied. I am completely stuck at this point and would appreciate any help to resolve this.
Most probably the mdf file is locked by some other process, not allowing the application to read it. If you mounted the database on SQL Server you need to use a connection string with the machine name instead of specifying the mdf file directly.
You can't copy or modify a live working database. And I don't see why you should.
You need connecting to it? Pick a way. LINQ to SQL, Entity Framework, NHibernate, ADO.NET...
If you really want to copy the database file for some reason, you must first stop the MSSQL Service (or detach the database), then do that.
Like others have said, you shouldn't need to add the actual .mdf into your project. If you have it running on your local SQL Server instance, you should be able to add it via Visual Studio's Server Explorer (plus that gets you your connection string).

Resources