- VERSION 4.11.09

- Commit inicial
This commit is contained in:
Jose Alberto Guerra Ugalde
2024-11-09 01:58:44 -06:00
parent 431c839668
commit 9bf8b82adf
24 changed files with 2561 additions and 0 deletions

81
RDCConnector.bas Normal file
View File

@@ -0,0 +1,81 @@
B4J=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=4.19
@EndOfDesignText@
'Class module
Sub Class_Globals
Private pool As ConnectionPool
Private DebugQueries As Boolean
Dim commands As Map
Public serverPort As Int
Public usePool As Boolean = True
Dim config As Map
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(DB As String)
' Log("RDCConnector Initialize")
If DB.EqualsIgnoreCase("DB1") Then DB = "" 'Esto para el config.properties or default
' If DB.EqualsIgnoreCase("DB1") Then DB = "" 'Esto para el config.properties or default
Dim config As Map = LoadConfigMap(DB)
Log($"Inicializamos ${DB}, usuario: ${config.Get("User")}"$)
pool.Initialize(config.Get("DriverClass"), config.Get("JdbcUrl"), config.Get("User"), _
config.Get("Password"))
#if DEBUG
DebugQueries = True
#else
DebugQueries = False
#end if
serverPort = config.Get("ServerPort")
If DB = "" Then DB = "DB1"
LoadSQLCommands(config, DB)
End Sub
'Sub closePool
' If pool.GetConnection.IsInitialized Then
' pool.ClosePool
' Log("----- Cerramos pool")
' End If
'End Sub
Private Sub LoadConfigMap(DB As String) As Map
Private DBX As String = ""
If DB <> "" Then DBX = "." & DB
Log("===========================================")
Log($"Leemos el config${DBX}.properties"$)
Return File.ReadMap("./", "config" & DBX & ".properties")
End Sub
Public Sub GetCommand(DB As String, Key As String) As String
' Log("==== GetCommand ====")
' Log("|" & Key & "|")
commands = Main.commandsMap.get(DB).As(Map)
If commands.ContainsKey("sql." & Key) = False Then
Log("*** Command not found: " & Key)
End If
Log("**** " & Key & " ****")
Log(commands.Get("sql." & Key))
Return commands.Get("sql." & Key)
End Sub
Public Sub GetConnection(DB As String) As SQL
If DB.EqualsIgnoreCase("DB1") Then DB = "" 'Esto para el config.properties or default
If DebugQueries Then LoadSQLCommands(LoadConfigMap(DB), DB)
Return pool.GetConnection
End Sub
Private Sub LoadSQLCommands(config2 As Map, DB As String)
Log($"Cargamos los comandos desde el config.${DB}.properties"$)
Dim newCommands As Map
newCommands.Initialize
For Each k As String In config2.Keys
If k.StartsWith("sql.") Then
newCommands.Put(k, config2.Get(k))
End If
Next
commands = newCommands
' Log($"Inicializado: ${DB} "$ & Main.commandsMap.IsInitialized)
Main.commandsMap.Put(DB, commands)
End Sub