Subject | Re: Embedded backup (was: setAutocommit ...) |
---|---|
Author | nagypapi |
Post date | 2005-09-11T14:42:52Z |
Here's more or less what I used for testing.
You can run it without an argument - it will then try PURE_JAVA
backup, or the first argument specifies what kind of backup it should try.
Change the variables in the code to match your connection parameters.
java file content:
import java.sql.*;
import org.firebirdsql.management.*;
class JBIRD2PureJavaError {
Connection conn;
//set these to your bidding
String dbuser="SYSDBA",dbpass="masterkey",
role=null,charset="UNICODE_FSS";
String databasePath="pathToYourDB";
static String backup_type="PURE_JAVA";
public static void main(String args[]) {
if(args.length>0) backup_type=args[0];
new JBIRD2PureJavaError();
}
JBIRD2PureJavaError() {
conn=null;
try{ Class.forName("org.firebirdsql.jdbc.FBDriver").newInstance();
String connstring="jdbc:firebirdsql:embedded:"+databasePath;
if(charset!=null||role!=null) connstring+="?";
connstring+=charset!=null?"lc_ctype="+charset+(role!=null?"&":""):"";
connstring+=role!=null?"sql_role_name="+role:"";
conn = DriverManager.getConnection(connstring,dbuser,dbpass);
} catch(Exception e) {
e.printStackTrace(System.out);
}
System.out.println("Backing up with backup type "+backup_type+":");
try{
FBBackupManager fbBackup=new FBBackupManager(backup_type);
fbBackup.setUser(dbuser);
fbBackup.setPassword(dbpass);
//fbBackup.setHost("localhost");
fbBackup.setDatabase(databasePath);
fbBackup.setBackupPath(databasePath+".fbk");
fbBackup.setLogger(System.out);
fbBackup.setVerbose(true);
fbBackup.backupDatabase();
} catch(Exception e) {e.printStackTrace(System.out);}
try{conn.close();}catch(Exception e) {e.printStackTrace(System.out);}
}
}
--- In Firebird-Java@yahoogroups.com, "Roman Rokytskyy"
<rrokytskyy@a...> wrote:
You can run it without an argument - it will then try PURE_JAVA
backup, or the first argument specifies what kind of backup it should try.
Change the variables in the code to match your connection parameters.
java file content:
import java.sql.*;
import org.firebirdsql.management.*;
class JBIRD2PureJavaError {
Connection conn;
//set these to your bidding
String dbuser="SYSDBA",dbpass="masterkey",
role=null,charset="UNICODE_FSS";
String databasePath="pathToYourDB";
static String backup_type="PURE_JAVA";
public static void main(String args[]) {
if(args.length>0) backup_type=args[0];
new JBIRD2PureJavaError();
}
JBIRD2PureJavaError() {
conn=null;
try{ Class.forName("org.firebirdsql.jdbc.FBDriver").newInstance();
String connstring="jdbc:firebirdsql:embedded:"+databasePath;
if(charset!=null||role!=null) connstring+="?";
connstring+=charset!=null?"lc_ctype="+charset+(role!=null?"&":""):"";
connstring+=role!=null?"sql_role_name="+role:"";
conn = DriverManager.getConnection(connstring,dbuser,dbpass);
} catch(Exception e) {
e.printStackTrace(System.out);
}
System.out.println("Backing up with backup type "+backup_type+":");
try{
FBBackupManager fbBackup=new FBBackupManager(backup_type);
fbBackup.setUser(dbuser);
fbBackup.setPassword(dbpass);
//fbBackup.setHost("localhost");
fbBackup.setDatabase(databasePath);
fbBackup.setBackupPath(databasePath+".fbk");
fbBackup.setLogger(System.out);
fbBackup.setVerbose(true);
fbBackup.backupDatabase();
} catch(Exception e) {e.printStackTrace(System.out);}
try{conn.close();}catch(Exception e) {e.printStackTrace(System.out);}
}
}
--- In Firebird-Java@yahoogroups.com, "Roman Rokytskyy"
<rrokytskyy@a...> wrote:
> > 1. "PURE_JAVA" constructor created FBBackupManager throws theWhen you
> > following exception if I backupDatabase():
>
> Do you have a test case or small code snippet for it?
>
> > 2. I created an FBBackupManager with an "EMBEDDED" constructor
> > parameter. By default I set the host to setHost("localhost"). Because
> > of this, the backupDatabase always threw a
> > "org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544344. I/O
> > error for file CreateFile (open) ..."
>
> Which is correct, since embedded can also act as a client library.
> specify the host name, you tell it to go to the specified serverinstead of
> accessing the local db.issue to
>
> > 3. It finds and uses jaybird2.dll and fbembed.dll if I place them in
> > the program's (working) dir, but it doesn't find firebird.msg, which I
> > eventually placed in windows/system32.
>
> Also correct, since this path is controlled by the firebird.conf and
> %FIREBIRD% variables.
>
> > (4. If I don't set user or pass with setUser/setPassword it throws a
> > NullPointerException which is perfectly correct, just not very
> > informative)
>
> Bad - if I'm not mistaken, embedded works ok also without user name and
> password. :) Thanks for the report!
>
> > event handling from java and built in java language support are the
> > other two features I'm interested in (my interest in the second is
> > partly because of the lack of the first). I haven't found anything
> > about them on the Wiki, is there any info about anyone implementing
> > event handling
>
> Gabriel Reid has already implemented event handling, there is small
> fix, butevents will be supported in JayBird 2.1, which will bestarted right
> after the 2.0 final release. In other words - "comming soon" :)
>
> > or how java procedural language is progressing?
>
> Will be released soon in Fyracle project. The integration into the main
> trunk is not yet planned, but actively discussed (though in Russian
> mainly) - we're not yet settled on some basic concepts for external
> procedures in general.
>
> Roman