I use the "replace" trick to replace the database name in JdbcUrl.
[CODE lang="b4x" highlight="7"]Public Sub Init(DBUser As String, DBPassword As String, DBName As String) As Boolean
Dim Success As Boolean
Try
DriverClass = Main.settings.Get("DriverClass")
JdbcUrl = Main.settings.Get("JdbcUrl")
If DBName <> "" Then
JdbcUrl = JdbcUrl.ToLowerCase.Replace("test", DBName)
End If
pool.Initialize(DriverClass, JdbcUrl, DBUser, DBPassword)
con = pool.GetConnection
If con.IsInitialized Then
Success = True
Else
Success = False
End If
Catch
LogError(LastException)
Exceptions = LastException.Message
Success = False
End Try
If con <> Null And con.IsInitialized Then con.Close
If pool.IsInitialized Then pool.ClosePool
Return Success
End Sub[/CODE]
This app is inspired by Adminer (a lightweight app to manage mySQL database). I haven't seen any web app built using B4J to manage remote MySQL database, so I build one. This project is still work in progress. I also successfully tested that I can run 2 B4J servers in the same VPS using...
www.b4x.com