Thomas ,

To avoid problems like you desribed we nowadays uses the "com.sun.star.sdb.DatabaseContext" as a "binding" point to our MySQL server. So we place a OO-DB-document where all OO- users can acces the document with the lowest posible rights ( to avoid unwanted acces to the MySQL Tables) The we declare this DB-doc as a database in OO with a stadard name like "mysql_native"
For connecting we uses in our macro's:

oDB = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oConn = oDB.GetByName("mysql_native").GetConnection("username","password")

We change "username" and "password" in our macro's (who are scrambled) depending on the aplication needs This aproach has also the advantage that you can make MySQL data available in the Beamer (Datasource browser)

Hope it helps

Fernand
Hey,

I do have al lot of problems trying to connect to a MySQL Database via
Sun native driver.
Funny: When I install the driver last week, everything works well, I got
the connection-object and could work with it.
This week - I only get errors.
Even, when I try to connect via UI- just errors.
Today at first I got errors, then could connect via UI by changeing the
IP - so, not use 127.0.0.1 but the static IP-Adress of the PC:

Neverthless - using my code (see below) I always get the following error:
Type:com.sun.star.sdbc.SQLException
Message: Can`t connect to MySQL server on '127.0.0.1' (10013)

Even when I changed the IP on complete different IP-Numbers (existing
and non existing) - the Error-Message is still the same )(with IP
127.0.0.1 - localhost)

My MySQL-Server is working fine, I can connect via MySQL Administrator
and even it works today using the JDBC Driver instead of the nativ driver.

The following code works fine last week - not any more today. Any
suggestions?

function TIMM_getConnection()
  dim oCon as variant  'Connection-Objekt
  dim oDM as variant   'TreiberManager
  dim dbprop(1) as new com.sun.star.beans.PropertyValue

  dbprop(0).name = "user"
  dbprop(0).value = "SWB"
  dbprop(1).name = "password"
  dbprop(1).value = "swb"

  oDM = createUnoService("com.sun.star.sdbc.DriverManager")

  oCon =
oDM.getConnectionWithInfo("sdbc:mysql:mysqlc://127.0.0.1:3306/timm",
dbprop())
  oCon.setCatalog("timm")
  TIMM_getConnection = oCon
End function

Best regards
Thomas



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to