Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello,

Your question is too broad to give details on this answer in a forum. To establish a connection, there is an example in the "AndrewBase" document found on this page. See section 8.6.5 of that document for more information. Once you make a connection you need to send a request to the DB for what is wanted and the return is a 'Result Set'. Information about Result Sets and using data returned can be found on this AOO Wiki starting here.

As for How to get current connection info? (ip, port, user, password), that is determined on the user side when MySQL was installed. If you don't have this info you need to get it from the DB administrator.

Hello,

Your question is too broad to give details on this answer in a forum. To establish a connection, there is an example in the "AndrewBase" document found on this page. See section 8.6.5 of that document for more information. Once you make a connection you need to send a request to the DB for what is wanted and the return is a 'Result Set'. Information about Result Sets and using data returned can be found on this AOO Wiki starting here.

As for How to get current connection info? (ip, port, user, password), that is determined on the user side when MySQL was installed. If you don't have this info you need to get it from the DB administrator.

Edit 10/08/2017:

Sorry for misunderstanding your original question but it does contain relevant information. The answer you provided has given better information and would be nice as part of the question.

From this it seems you want access to the same information which is under the menu selection Edit->Database->Properties. Two ways I can think of to get this information.

Locally, this information is stored within one of the files zipped in the .odb - content.xml file. You would need to extract the data from this portion (beginning of section sample):

image description

From the connected .odb you can use a macro, as previously stated, by creating a connection and retrieving the Meta data:

    oContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oDB = oContext.getByName(sDBName)
oCon = oDB.getConnection(sUserName,sUserPW) 

REM Use above three line for connection or the previously mentioned connection from section 8.6.5

oMeta = oCon.getMetaData()
connMeta = oMeta.getConnection().getMetaData()
print connMeta.URL
print connMeta.UserName

sDBName is either the registered name or the .odb URL.

The URL will be something like: sdbc:mysql:mysqlc:192.135.214.251:3306/YOUR_DB

Don't know of any way to retrieve the password as you request.

Even after all that, it is not clear as to why you need to change all the code. Changing the connection is all you should need. I'm not even certain what I presented is what you are looking for.

Hello,

Your question is too broad to give details on this answer in a forum. To establish a connection, there is an example in the "AndrewBase" document found on this page. See section 8.6.5 of that document for more information. Once you make a connection you need to send a request to the DB for what is wanted and the return is a 'Result Set'. Information about Result Sets and using data returned can be found on this AOO Wiki starting here.

As for How to get current connection info? (ip, port, user, password), that is determined on the user side when MySQL was installed. If you don't have this info you need to get it from the DB administrator.

Edit 10/08/2017:

Sorry for misunderstanding your original question but it the answer does contain relevant information. The answer you provided has given better information and would be nice as part of the question.

From this it seems you want access to the same information which is under the menu selection Edit->Database->Properties. Two ways I can think of to get this information.

Locally, this information is stored within one of the files zipped in the .odb - content.xml file. You would need to extract the data from this portion (beginning of section sample):

image description

From the connected .odb you can use a macro, as previously stated, by creating a connection and retrieving the Meta data:

    oContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oDB = oContext.getByName(sDBName)
oCon = oDB.getConnection(sUserName,sUserPW) 

REM Use above three line for connection or the previously mentioned connection from section 8.6.5

oMeta = oCon.getMetaData()
connMeta = oMeta.getConnection().getMetaData()
print connMeta.URL
print connMeta.UserName

sDBName is either the registered name or the .odb URL.

The URL will be something like: sdbc:mysql:mysqlc:192.135.214.251:3306/YOUR_DB

Don't know of any way to retrieve the password as you request.

Even after all that, it is not clear as to why you need to change all the code. Changing the connection is all you should need. I'm not even certain what I presented is what you are looking for.

Hello,

Your question is too broad to give details on this answer in a forum. To establish a connection, there is an example in the "AndrewBase" document found on this page. See section 8.6.5 of that document for more information. Once you make a connection you need to send a request to the DB for what is wanted and the return is a 'Result Set'. Information about Result Sets and using data returned can be found on this AOO Wiki starting here.

As for How to get current connection info? (ip, port, user, password), that is determined on the user side when MySQL was installed. If you don't have this info you need to get it from the DB administrator.

Edit 10/08/2017:

Sorry for misunderstanding your original question but the answer does contain relevant information. The answer you provided has given better information and would be nice as part of the question.

From this it seems you want access to the same information which is under the menu selection Edit->Database->Properties. Two ways I can think of to get this information.

Locally, this information is stored within one of the files zipped in the .odb - content.xml file. You would need to extract the data from this portion (beginning of section sample):

image description

From the connected .odb you can use a macro, as previously stated, by creating a connection and retrieving the Meta data:

    oContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oDB = oContext.getByName(sDBName)
oCon = oDB.getConnection(sUserName,sUserPW) 

REM Use above three line for connection or the previously mentioned connection from section 8.6.5

oMeta = oCon.getMetaData()
connMeta = oMeta.getConnection().getMetaData()
print connMeta.URL
print connMeta.UserName

sDBName is either the registered name or the .odb URL.

The URL connMeta.URL you can retrieve will be something like: sdbc:mysql:mysqlc:192.135.214.251:3306/YOUR_DB

Don't know of any way to retrieve the password as you request.

Even after all that, it is not clear as to why you need to change all the code. Changing the connection is all you should need. I'm not even certain what I presented is what you are looking for.

Hello,

Your question is too broad to give details on this answer in a forum. To establish a connection, there is an example in the "AndrewBase" document found on this page. See section 8.6.5 of that document for more information. Once you make a connection you need to send a request to the DB for what is wanted and the return is a 'Result Set'. Information about Result Sets and using data returned can be found on this AOO Wiki starting here.

As for How to get current connection info? (ip, port, user, password), that is determined on the user side when MySQL was installed. If you don't have this info you need to get it from the DB administrator.

Edit 10/08/2017:

Sorry for misunderstanding your original question but the answer does contain relevant information. The answer you provided has given better information and would be nice as part of the question.

From this it seems you want access to the same information which is under the menu selection Edit->Database->Properties. Two Three ways I can think of to get this information.

Locally, this information is stored within one of the files zipped in the .odb - content.xml file. You would need to extract the data from this portion (beginning of section sample):

image description

From the connected .odb you can use a macro, as previously stated, by creating a connection and retrieving the Meta data:

    oContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oDB = oContext.getByName(sDBName)
oCon = oDB.getConnection(sUserName,sUserPW) 

REM Use above three line for connection or the previously mentioned connection from section 8.6.5

oMeta = oCon.getMetaData()
connMeta = oMeta.getConnection().getMetaData()
print connMeta.URL
print connMeta.UserName

sDBName is either the registered name or the .odb URL.

The connMeta.URL you can retrieve will be something like: sdbc:mysql:mysqlc:192.135.214.251:3306/YOUR_DB

Don't know of any way to retrieve the password as you request.

The last way ThisDatabaseDocument.DataSource.URL retrieve the same info as in the Meta data.

Even after all that, it is not clear as to why you need to change all the code. Changing the connection is all you should need. I'm not even certain what I presented is what you are looking for.