Ask Your Question
0

Cannot assign parameters to drivermanager

asked 2018-09-05 15:13:07 +0200

MarjanMr gravatar image

updated 2018-09-06 06:58:59 +0200

Ok, here's the deal:

I want to connect to mysql. The code is working, however, I cannot assign user and password to connecton, it allways returns error "you(logged username) are not allowed to connect."

Properties are assigned like this:

Dim oParms(2) As New com.sun.star.beans.PropertyValue

oParms(0).Name = "user"

oParms(0).Value = "root"

oParms(1).Name = "password"

oParms(1).Value = "" 'or nothing, it doesn't work with any; password is EMPTY

oManager = CreateUnoService("com.sun.star.sdbc.DriverManager")

sURL = "sdbc:mysql:mysqlc:hostname:port/database"

oCon = oManager.getconnection(surl, oParms)

What the hell am I doing wrong? This is driving me nuts!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-09-05 18:10:06 +0200

Ratslinger gravatar image

updated 2018-09-05 18:49:27 +0200

Hello,

For the user & password (your code should work; this is just alternative):

  Dim oParms() As New com.sun.star.beans.PropertyValue
  AppendProperty(oParms(), "user", "root")
  AppendProperty(oParms(), "password", "PASSWORD_HERE")

Also change oCon line to - cause of problem:

oCon = oManager.getConnectionWithInfo(sURL, oParms())

And of course, insure you have correct host/port/database names in sURL string.

edit flag offensive delete link more

Comments

The last line, getConnectionWithInfo, did the trick.

Thanks alot!

MarjanMr gravatar imageMarjanMr ( 2018-09-06 07:24:08 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-09-05 15:13:07 +0200

Seen: 34 times

Last updated: Sep 06 '18