In your Java app on Linux, change the db connection string to point to the
old MySQL db server in Windows.

For Linux, you can download MM JDBC driver from MySQL Contribution. Install
and set-up by following the instruction.

Set your dbURL =
"jdbc:mysql://YOUR_WINDOWS_HOST_NAME/IP:3306/YOUR_DB_NAME"; at
DriverManager.getConnection( dbURL, username, pwd);

Make sure the username has the privledge to access from Linux machine.

Then you can access Windows DB from Java app at Linux without rewrite your
Java app code.

More flexible, you'd better put the YOUR_WINDOWS_HOST_NAME/IP into a
property text file. e.g. YOUR_DB.ini. In it has a line
datasourceMachine=YOUR_WINDOWS_HOST_NAME/IP

// works fine JDK 1.1.7 or above.
// take care about the path of YOUR_DB.ini. OK if the file locates in same
directory.
String dataSourceMachine;
 InputStream is = ClassLoader.getSystemResourceAsStream ("YOUR_DB.ini");
 Properties p = new Properties();
 p.load (is);
 dataSourceMachine = p.getProperty("datasourceMachine","localhost");
.
.
.
dbURL =  "jdbc:mysql://"+dataSourceMachine+":3306/YOUR_DB_NAME";

For "really" same Java code, just change the property file from machine to
machine.


Good luck.


----- Original Message -----
From: "Sibel Toprakkiran" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 26, 2001 5:09 PM
Subject: java & mysql


> Hi,
>
> I have a Java program, from which I'm accessing the
> data in a mysql database via jdbc. I want to run the
> program on linux and on windows, without changing the
> code. I was using the jdbc-odbc driver on Windows, but
> on linux I can't use this.
> I would be glad, if someone knows, how to manage this
> problem.
>
> Thanks and regards,
> sibel.
>
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to