|
Home > Archive > SQL Anywhere database > July 2005 > Autostart the Sybase database engine (dbeng9.exe or rteng9.exe) using JDBC
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Autostart the Sybase database engine (dbeng9.exe or rteng9.exe) using JDBC
|
|
| Melody Pedzisai 2005-06-29, 8:23 pm |
| Hallo
I am looking for a way to startup the database engine from a Java program
that is using JDBC to connect to a Sybase 9 database. In other words I need
to be able to get my users to open a .db file and fire the database engine
automatically withou having to call a Java Runtime command.
Is there any way to do that or is the only way to connect to a database
using JDBC is to have the engine running already?
Thanks
Melody
| |
| Melody Pedzisai 2005-07-12, 8:23 pm |
| Greg
Thanks for the response to my post. I use both JConnect and IAnywhere and
was hopying to be able to startup the database engine (I will be using
rteng9.exe when the project is finished by I am current using dbeng9) for
both of them. I understand what you said that I can only do it if I use
IAnywhere. Below is the code that I currently use to startup the database in
file specified as as_path
[CODE]
public static boolean connectIAnywhere(Str
ing as_dbpath, String as_user,
String as_password) throws SQLException, ClassNotFoundExcepti
on, Exception {
String driver, url;
driver="ianywhere.ml.jdbcodbc.IDriver";
url = "jdbc:odbc:";
url += "driver=Adaptive Server Anywhere
9.0";//"?start=dbeng9.exe&autostop=yes&dbf="+as_dbpath;
Class.forName( driver );
connection = DriverManager.getConnection(url, as_user, as_password);
connection. setAutoCommit(false)
;
return true;
}
[/CODE]
Note the commented out code in the method above
url += "driver=Adaptive Server Anywhere
9.0";//"?start=dbeng9.exe&autostop=yes&dbf="+as_dbpath;
In the setting of the URL . I wanted to add the start=dbeng9.exe and
dbf=as_path as part of the URL so that the database would be started and
stopped automatically as appropriate. It did not work so I ended up using
the Java Runtim.getRuntime().exec("command") construct to start the database
engine before the above method is called to load the driver, which is a
problem because if the engine is already running it gives me an error. There
is also no easy way to know when the exec command has finished executing so
that Ican then load the drivers.
Bottom line is that I want the URL line above (or anything else ) to point
to a file and the engine required so that the engine can be started
automatically if it was not already started and stoppped as soon as the db
is closed.
Thanks,
Melody
"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
news:42c34e67$1@foru
ms-2-dub...
> Melody Pedzisai wrote:
>
> If you use the iAnywhere JDBC driver and *not* jConnect, then you can
> accomplish this by supplying the appropriate parameters. Specifically,
> you must specify DBF pointing to a file on the *same* machine that your
> application is running on and you must *not* specify a network-only
> connection link.
>
> If you aren't sure, try posting your connection parameters so we can see
> what you are doing.
>
> Hope this helps,
> greg.fenton
> --
> Greg Fenton
> Consultant, Solution Services, iAnywhere Solutions
> --------
> Visit the iAnywhere Solutions Developer Community
> Whitepapers, TechDocs, Downloads
> http://www.ianywhere.com/developer/
| |
| Melody Pedzisai 2005-07-19, 8:23 pm |
| Thanks Greg. Everything works like clockwork now!
"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
news:42d479fe$1@foru
ms-1-dub...
> Melody Pedzisai wrote:
>
> What is the "?" in the URL for? There should not be one.
> Also, arguments in a connection string are separated by ";", not "&".
> So the URL I think you are trying to use should be:
>
> url = "jdbc:odbc:" +
> "driver=Adaptive Server Anywhere 9.0" +
> ";start=dbeng9. exe;autostop=yes;dbf
=" + as_dbpath;
>
>
> Also, if the above is failing to connect, as I mentioned in my previous
> post try adding ";LOG=c:/asa_connection.txt" to the connection-string of
> your URL. After a connection attempt, the file c:/asa_connection.txt
> (or whatever path your provide to the LOG param) will contain diagnostic
> infromation about the connection attempt.
>
> I would also suggest adding the full-path to the "dbeng9.exe" (or
> rteng9.exe), something along the lines of:
>
> ";start=" + PATH_TO_ASA_INSTALL + "/win32/dbeng9.exe"
>
> where you might get the value of PATH_TO_ASA_INSTALL from the ASANY9
> environment variable.
>
> greg.fenton
> --
> Greg Fenton
> Consultant, Solution Services, iAnywhere Solutions
> --------
> Visit the iAnywhere Solutions Developer Community
> Whitepapers, TechDocs, Downloads
> http://www.ianywhere.com/developer/
|
|
|
|
|