0

I recently encountered a legacy code (Delphi 2007). There is a SYSTEM.IB file while I believe it's the database file.

The program is roughly as follows:

ibSys: TIBDatabase;

// The following will throw exception username and password are not defined.
// Ask your database admin to set up an InterBase login
procedure TNHP_CommonDB.IB_SystemOpen(Apath: string):
begin
  ibSys.DatabaseName := Apath + '\SYSTEM.IB';
  try
    ibSys.Open;
  except
    raise;
  end;
end;

I think the default username is sysdba, and default password is masterkey. I installed Interbase without changing the default password.

So How should I deal with this exception?

Thanks.

user534498
  • 3,926
  • 5
  • 27
  • 52
  • Well, you could start by reading the documentation, which would tell you how to set the username and password. – Ken White Jun 07 '16 at 12:48
  • The problem is, the program source code doesn't provide username/password, what usernane/password shall I change to? Just putting to -1 without reading carefully on the question is just purely ignorant. – user534498 Jun 07 '16 at 13:20
  • I did read the question. You said *How should I deal with this exception?*, to which the answer is *Provide the proper username and password*. You didn't ask *How do I figure out the password if it isn't the default?*, which is what your comment implies. I vote on questions based on what they say, not on what you meant to ask instead. Johan apparently read it the same way I did, because he also told you how to set the username and password. – Ken White Jun 07 '16 at 18:02
  • My question actually asks how to solve it, whether it's setup username/password of Interbase, or add username/password into the source code, or if you know why it happens (why the original code doesn't have username/password adding in but the original source code should work)? – user534498 Jun 08 '16 at 01:18
  • Your question contains 6 lines of code (between the begin..end), four of which are `try except raise; end;`. How do you expect us to know how that code works or where the user/password are being set, or what user/password it is expecting? You have the entire source code available to you to figure that out - how do you expect us to do it with no information available to us? Read the documentation - it tells you exactly how to specify a username and password to Interbase. You, of course, have to know the username and password to provide. We're not a tutorial site, and we're not psychic. – Ken White Jun 08 '16 at 01:22
  • I tried debugging into it, trust me there's no other relavent code regarding database settings involved. The original code contains 0.5 million lines of source code and it should work before (it's just not working right now). I am new to Interbase and delphi, to me I don't even know setting username/password is a must because the legacy code doesn't contain any password settings. My guess currently is probably some versions of Delphi will auto set password to default masterkey if you don't set them? Just a guess. – user534498 Jun 08 '16 at 01:29
  • Delphi doesn't *auto set* any password or username. It's either done in the code, stored in the properties in a DFM (form file) somewhere, or your DB doesn't have one. In any of those cases, it's not in the two lines of relevant code you posted here. – Ken White Jun 08 '16 at 01:30
  • Frankly I am not asking how to set username/password in source code, I can check and search the docs of course, I am just not sure what shall I do given the exception raised. Is it because some hidden username/password in Interbase I didn't set? Is it because the System.IB file contains some hidden username/password so that I should set some hidden file or hidden environment parameter? I know nothing, therefore I ask how to solve. If you think it's I should set it in source code, I will set it myself. Thanks anyway. – user534498 Jun 08 '16 at 01:32
  • Thanks. I will check DFM files too. Probably it's there but not correctly opened or contained in the current project. – user534498 Jun 08 '16 at 01:33
  • I actually don't really get the point, why Interbase requires username/password to open System.IB (a database file?) Open System.IB in source code means that it is similar to sqlite, but sqlite doesn't require system-level username/password. Mysql/Oracle do require system-level username/password, but they don't operate in file level (at least not exposing files to users). – user534498 Jun 08 '16 at 01:36
  • Because real DBMS systems have security that prevents unauthorized users from getting to the data or making changes they're not supposed to make. SQLite is not a actual DBMS. MySQL/Oracle/SQL Server all require DBA credentials to access databases. (Yes, even from exposing files to users - you have to log in to the DB itself before you can see what it contains, including tables, users, stored procedures, etc.) It seems Delphi is not the only thing with which you're not familiar. You should find a good database administration book. – Ken White Jun 08 '16 at 01:40
  • You still not getting my point. Exposing the file (System.IB) to users make Interbase looks similar to sqlite, in which I can copy the files around. I am not even sure whether the username/password shown in exception is because System.IB itself contains username/password information or not. I don't even know Interbase is a proper DBMS (never used it). So what you think is: I should go to get an Interbase 2007 handbook and read/search from beginning to end, to find out whether they add username/password to indivisual file, rather than asking here? It's not easy to get such information. – user534498 Jun 08 '16 at 02:04
  • Btw, Interbase is very counter-intuitive to me. username/password is only set in current machine (management level) ,and different usersname/passwords have different previlige to different files? But files can be copied to different machines so easily as sqlite? – user534498 Jun 08 '16 at 02:05
  • Given the exeption (username/password not correct), and given the source code, there are so many possible reasons to me, trying to identify each one takes too long time. If you think I should go search, I did search, and find many ppl asking about this exception, but none of the answers solve my doubts. Therefore I have this question. – user534498 Jun 08 '16 at 02:11
  • If you're running Interbase Server, you can't just copy the file around, and you certainly can't access it's internals (tables, etc.) without the password. Just like every other database, the users and passwords are stored in the DB itself. Users can be given restricted access (SELECT only, for instance) by the DB administrator. This is also the case in other real DBMS systems. Any book on DB administration can give you the basics of DB security and access control, which is why I suggested you find one. This site isn't going to tutor you in DB administration basics. – Ken White Jun 08 '16 at 02:11
  • You are just wrong. I am running the interbase server, and the source code and System.IB file is given to me (copied from another machine). I can replicate it to as many machines as I want, and open this file by ibSys.DatabaseName := 'SYSTEM.IB'. I am not asking you what Interbase is, I have no intersts in that, I am just asking you how to solve this exception, which I am not sure what does it really mean given the source code that opens the database file. – user534498 Jun 08 '16 at 02:16
  • You *solve the exception* by **providing the proper username and password**. You've already been told how to pass that username and password. We can't tell you *what* username and password to use. You're clearly not listening, so I'll stop trying now. Good luck. – Ken White Jun 08 '16 at 02:25

1 Answers1

3

It is clearly documented in the docwiki for TIBDatabase:

The user_name and password are set in the params property.

    IBDatabaseInstance.Params.Clear; // Clear any previously-set parameter.
    IBDatabaseInstance.Params.Add('user_name=SYSDBA');
    IBDatabaseInstance.Params.Add('password=masterkey');
Johan
  • 74,508
  • 24
  • 191
  • 319
  • Thanks it works, but I just don't understand why the original source code doesn't have username password set but it should work before? I used delphi 2007 and interbase 2007 (the original source code also used the same version). – user534498 Jun 08 '16 at 01:21