mirror of
https://github.com/KeymonSoft/jRDC-Multi.git
synced 2026-04-18 05:09:32 +00:00
- VERSION 4.11.14
- Se agregó el parametro "setMaxPoolSize=5" para que solo genere 5 conexiones a la base de datos, antes generaba 15. - Se quitaron lineas previamente comentadas.
This commit is contained in:
@@ -30,27 +30,26 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
|
|||||||
Dim con As SQL
|
Dim con As SQL
|
||||||
Try
|
Try
|
||||||
con = Connector.GetConnection("DB1")
|
con = Connector.GetConnection("DB1")
|
||||||
' con = Main.rdcConnectorDB1.GetConnection("")
|
|
||||||
If method = "query2" Then
|
If method = "query2" Then
|
||||||
q = ExecuteQuery2("DB1", con, in, resp)
|
q = ExecuteQuery2("DB1", con, in, resp)
|
||||||
'#if VERSION1
|
'#if VERSION1
|
||||||
Else if method = "query" Then
|
Else if method = "query" Then
|
||||||
in = cs.WrapInputStream(in, "gzip")
|
in = cs.WrapInputStream(in, "gzip")
|
||||||
q = ExecuteQuery("DB1", con, in, resp)
|
q = ExecuteQuery("DB1", con, in, resp)
|
||||||
Else if method = "batch" Then
|
Else if method = "batch" Then
|
||||||
in = cs.WrapInputStream(in, "gzip")
|
in = cs.WrapInputStream(in, "gzip")
|
||||||
q = ExecuteBatch("DB1", con, in, resp)
|
q = ExecuteBatch("DB1", con, in, resp)
|
||||||
'#end if
|
'#end if
|
||||||
Else if method = "batch2" Then
|
Else if method = "batch2" Then
|
||||||
q = ExecuteBatch2("DB1", con, in, resp)
|
q = ExecuteBatch2("DB1", con, in, resp)
|
||||||
Else
|
Else
|
||||||
Log("Unknown method: " & method)
|
Log("Unknown method: " & method)
|
||||||
resp.SendError(500, "unknown method")
|
resp.SendError(500, "unknown method")
|
||||||
End If
|
End If
|
||||||
Catch
|
Catch
|
||||||
Log(LastException)
|
Log(LastException)
|
||||||
resp.SendError(500, LastException.Message)
|
resp.SendError(500, LastException.Message)
|
||||||
End Try
|
End Try
|
||||||
If con <> Null And con.IsInitialized Then con.Close
|
If con <> Null And con.IsInitialized Then con.Close
|
||||||
Log($"Command: ${q}, took: ${DateTime.Now - start}ms, client=${req.RemoteAddress}"$)
|
Log($"Command: ${q}, took: ${DateTime.Now - start}ms, client=${req.RemoteAddress}"$)
|
||||||
End Sub
|
End Sub
|
||||||
@@ -154,11 +153,11 @@ Private Sub ExecuteBatch(DB As String, con As SQL, in As InputStream, resp As Se
|
|||||||
WriteInt(r, out)
|
WriteInt(r, out)
|
||||||
Next
|
Next
|
||||||
out.Close
|
out.Close
|
||||||
Catch
|
Catch
|
||||||
con.Rollback
|
con.Rollback
|
||||||
Log(LastException)
|
Log(LastException)
|
||||||
resp.SendError(500, LastException.Message)
|
resp.SendError(500, LastException.Message)
|
||||||
End Try
|
End Try
|
||||||
Return $"batch (size=${numberOfStatements})"$
|
Return $"batch (size=${numberOfStatements})"$
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
|
|||||||
Dim con As SQL
|
Dim con As SQL
|
||||||
Try
|
Try
|
||||||
con = Connector.GetConnection("DB2")
|
con = Connector.GetConnection("DB2")
|
||||||
' con = Main.rdcConnectorDB2.GetConnection("DB2")
|
|
||||||
If method = "query2" Then
|
If method = "query2" Then
|
||||||
q = ExecuteQuery2("DB2", con, in, resp)
|
q = ExecuteQuery2("DB2", con, in, resp)
|
||||||
'#if VERSION1
|
'#if VERSION1
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
|
|||||||
Connector = Main.Connectors.Get("DB3")
|
Connector = Main.Connectors.Get("DB3")
|
||||||
Dim con As SQL
|
Dim con As SQL
|
||||||
Try
|
Try
|
||||||
' con = Main.rdcConnectorDB3.GetConnection("DB3")
|
|
||||||
con = Connector.GetConnection("DB3")
|
con = Connector.GetConnection("DB3")
|
||||||
If method = "query2" Then
|
If method = "query2" Then
|
||||||
q = ExecuteQuery2("DB3", con, in, resp)
|
q = ExecuteQuery2("DB3", con, in, resp)
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
|
|||||||
Connector = Main.Connectors.Get("DB4")
|
Connector = Main.Connectors.Get("DB4")
|
||||||
Dim con As SQL
|
Dim con As SQL
|
||||||
Try
|
Try
|
||||||
' con = Main.rdcConnectorDB4.GetConnection("DB4")
|
|
||||||
con = Connector.GetConnection("DB4")
|
con = Connector.GetConnection("DB4")
|
||||||
If method = "query2" Then
|
If method = "query2" Then
|
||||||
q = ExecuteQuery2("DB4", con, in, resp)
|
q = ExecuteQuery2("DB4", con, in, resp)
|
||||||
|
|||||||
@@ -17,12 +17,64 @@ End Sub
|
|||||||
'Initializes the object. You can add parameters to this method if needed.
|
'Initializes the object. You can add parameters to this method if needed.
|
||||||
Public Sub Initialize(DB As String)
|
Public Sub Initialize(DB As String)
|
||||||
' Log("RDCConnector Initialize")
|
' 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 por default
|
||||||
' If DB.EqualsIgnoreCase("DB1") Then DB = "" 'Esto para el config.properties or default
|
|
||||||
Dim config As Map = LoadConfigMap(DB)
|
Dim config As Map = LoadConfigMap(DB)
|
||||||
Log($"Inicializamos ${DB}, usuario: ${config.Get("User")}"$)
|
Log($"Inicializamos ${DB}, usuario: ${config.Get("User")}"$)
|
||||||
pool.Initialize(config.Get("DriverClass"), config.Get("JdbcUrl"), config.Get("User"), _
|
pool.Initialize(config.Get("DriverClass"), config.Get("JdbcUrl"), config.Get("User"), config.Get("Password"))
|
||||||
config.Get("Password"))
|
Dim jo As JavaObject = pool
|
||||||
|
jo.RunMethod("setMaxPoolSize", Array(5)) 'number of concurrent connections
|
||||||
|
|
||||||
|
' com.mchange.v2.c3p0.ComboPooledDataSource [
|
||||||
|
' acquireIncrement -> 3,
|
||||||
|
' acquireRetryAttempts -> 30,
|
||||||
|
' acquireRetryDelay -> 1000,
|
||||||
|
' autoCommitOnClose -> False,
|
||||||
|
' automaticTestTable -> Null,
|
||||||
|
' breakAfterAcquireFailure -> False,
|
||||||
|
' checkoutTimeout -> 20000,
|
||||||
|
' connectionCustomizerClassName -> Null,
|
||||||
|
' connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester,
|
||||||
|
' contextClassLoaderSource -> caller,
|
||||||
|
' dataSourceName -> 2rvxvdb7cyxd8zlw6dyb|63021689,
|
||||||
|
' debugUnreturnedConnectionStackTraces -> False,
|
||||||
|
' description -> Null,
|
||||||
|
' driverClass -> oracle.jdbc.driver.OracleDriver,
|
||||||
|
' extensions -> {},
|
||||||
|
' factoryClassLocation -> Null,
|
||||||
|
' forceIgnoreUnresolvedTransactions -> False,
|
||||||
|
' forceSynchronousCheckins -> False,
|
||||||
|
' forceUseNamedDriverClass -> False,
|
||||||
|
' identityToken -> 2rvxvdb7cyxd8zlw6dyb|63021689,
|
||||||
|
' idleConnectionTestPeriod -> 600,
|
||||||
|
' initialPoolSize -> 3,
|
||||||
|
' jdbcUrl -> jdbc:oracle:thin:@//10.0.0.110:1521/DBKMT,
|
||||||
|
' maxAdministrativeTaskTime -> 0,
|
||||||
|
' maxConnectionAge -> 0,
|
||||||
|
' maxIdleTime -> 1800,
|
||||||
|
' maxIdleTimeExcessConnections -> 0,
|
||||||
|
' maxPoolSize -> 5,
|
||||||
|
' maxStatements -> 150,
|
||||||
|
' maxStatementsPerConnection -> 0,
|
||||||
|
' minPoolSize -> 3,
|
||||||
|
' numHelperThreads -> 3,
|
||||||
|
' preferredTestQuery -> DBMS_SESSION.SET_IDENTIFIER('whatever'),
|
||||||
|
' privilegeSpawnedThreads -> False,
|
||||||
|
' properties -> {password=******, user=******},
|
||||||
|
' propertyCycle -> 0,
|
||||||
|
' statementCacheNumDeferredCloseThreads -> 0,
|
||||||
|
' testConnectionOnCheckin -> False,
|
||||||
|
' testConnectionOnCheckout -> True,
|
||||||
|
' unreturnedConnectionTimeout -> 0,
|
||||||
|
' userOverrides -> {},
|
||||||
|
' usesTraditionalReflectiveProxies -> False
|
||||||
|
' ]
|
||||||
|
|
||||||
|
' Dim jo2 As JavaObject = pool
|
||||||
|
' Log(jo2.GetField("END_TO_END_CLIENTID_INDEX"))
|
||||||
|
|
||||||
|
jo.RunMethod("setPreferredTestQuery", Array("BEGIN DBMS_SESSION.SET_IDENTIFIER('whatever'); END;"))
|
||||||
|
' jo.RunMethod("setPreferredTestQuery", Array("alter session set current_schema=MYSCHEMA"))
|
||||||
|
' jo2.RunMethod("setClientIdentifier",Array( "MAX")) ' Tiempo máximo de inactividad antes de cerrar una conexión
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
DebugQueries = True
|
DebugQueries = True
|
||||||
#else
|
#else
|
||||||
@@ -33,13 +85,6 @@ Public Sub Initialize(DB As String)
|
|||||||
LoadSQLCommands(config, DB)
|
LoadSQLCommands(config, DB)
|
||||||
End Sub
|
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 Sub LoadConfigMap(DB As String) As Map
|
||||||
Private DBX As String = ""
|
Private DBX As String = ""
|
||||||
If DB <> "" Then DBX = "." & DB
|
If DB <> "" Then DBX = "." & DB
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ Version=10
|
|||||||
#Region Project Attributes
|
#Region Project Attributes
|
||||||
#CommandLineArgs:
|
#CommandLineArgs:
|
||||||
#MergeLibraries: True
|
#MergeLibraries: True
|
||||||
' VERSION 4.11.09
|
' VERSION 4.11.14
|
||||||
'###########################################################################################################
|
'###########################################################################################################
|
||||||
'###################### PULL #############################################################
|
'###################### PULL #############################################################
|
||||||
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=git&Args=pull
|
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=git&Args=pull
|
||||||
@@ -48,10 +48,6 @@ Version=10
|
|||||||
|
|
||||||
Sub Process_Globals
|
Sub Process_Globals
|
||||||
Public srvr As Server
|
Public srvr As Server
|
||||||
' Public rdcConnectorDB1 As RDCConnector
|
|
||||||
' Public rdcConnectorDB2 As RDCConnector
|
|
||||||
' Public rdcConnectorDB3 As RDCConnector
|
|
||||||
' Public rdcConnectorDB4 As RDCConnector
|
|
||||||
Public const VERSION As Float = 2.23
|
Public const VERSION As Float = 2.23
|
||||||
Type DBCommand (Name As String, Parameters() As Object)
|
Type DBCommand (Name As String, Parameters() As Object)
|
||||||
Type DBResult (Tag As Object, Columns As Map, Rows As List)
|
Type DBResult (Tag As Object, Columns As Map, Rows As List)
|
||||||
@@ -65,7 +61,6 @@ Sub AppStart (Args() As String)
|
|||||||
srvr.Initialize("")
|
srvr.Initialize("")
|
||||||
Dim con As RDCConnector
|
Dim con As RDCConnector
|
||||||
Connectors = srvr.CreateThreadSafeMap
|
Connectors = srvr.CreateThreadSafeMap
|
||||||
' commandsMap = srvr.CreateThreadSafeMap
|
|
||||||
commandsMap.Initialize
|
commandsMap.Initialize
|
||||||
con.Initialize("DB1") 'Inicializamos el default de config.properties
|
con.Initialize("DB1") 'Inicializamos el default de config.properties
|
||||||
Connectors.Put("DB1", con)
|
Connectors.Put("DB1", con)
|
||||||
@@ -75,31 +70,28 @@ Sub AppStart (Args() As String)
|
|||||||
If cpFiles.Size > 0 Then
|
If cpFiles.Size > 0 Then
|
||||||
Log(cpFiles)
|
Log(cpFiles)
|
||||||
For i = 0 To cpFiles.Size - 1
|
For i = 0 To cpFiles.Size - 1
|
||||||
If cpFiles.Get(i) = "config.DB2.properties" Then
|
If cpFiles.Get(i) = "config.DB2.properties" Then ' Si existe el archivo DB2, lo usamos.
|
||||||
Dim con As RDCConnector
|
Dim con As RDCConnector
|
||||||
con.Initialize("DB2")
|
con.Initialize("DB2")
|
||||||
Connectors.Put("DB2", con)
|
Connectors.Put("DB2", con)
|
||||||
listaDeCP.Add("DB2")
|
listaDeCP.Add("DB2")
|
||||||
End If
|
End If
|
||||||
If cpFiles.Get(i) = "config.DB3.properties" Then
|
If cpFiles.Get(i) = "config.DB3.properties" Then ' Si existe el archivo DB3, lo usamos.
|
||||||
Dim con As RDCConnector
|
Dim con As RDCConnector
|
||||||
con.Initialize("DB3")
|
con.Initialize("DB3")
|
||||||
Connectors.Put("DB3", con)
|
Connectors.Put("DB3", con)
|
||||||
listaDeCP.Add("DB3")
|
listaDeCP.Add("DB3")
|
||||||
End If
|
End If
|
||||||
If cpFiles.Get(i) = "config.DB4.properties" Then
|
If cpFiles.Get(i) = "config.DB4.properties" Then ' Si existe el archivo DB4, lo usamos.
|
||||||
con.Initialize("DB4")
|
con.Initialize("DB4")
|
||||||
Connectors.Put("DB4", con)
|
Connectors.Put("DB4", con)
|
||||||
listaDeCP.Add("DB4")
|
listaDeCP.Add("DB4")
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
' con.Initialize("DB1") 'Inicializamos el default de config.properties
|
srvr.AddHandler("/test", "TestHandler", False) ' Agrega un manejador a la ruta "/test", asignando las solicitudes a la clase TestHandler, el último parámetro indica si el manejador debe ejecutar en un nuevo hilo (False en este caso)
|
||||||
' Connectors.Put("DB1", con)
|
|
||||||
' srvr.Port = con.serverPort
|
|
||||||
srvr.AddHandler("/test", "TestHandler", False)
|
|
||||||
srvr.AddHandler("/manager", "Manager", False)
|
srvr.AddHandler("/manager", "Manager", False)
|
||||||
srvr.AddHandler("/*", "DB1Handler", False)
|
srvr.AddHandler("/*", "DB1Handler", False) ' Si no se especifica una base de datos, entonces asignamos la solicitud a la DB1.
|
||||||
srvr.AddHandler("/db1", "DB1Handler", False)
|
srvr.AddHandler("/db1", "DB1Handler", False)
|
||||||
srvr.AddHandler("/DB1", "DB1Handler", False)
|
srvr.AddHandler("/DB1", "DB1Handler", False)
|
||||||
srvr.AddHandler("/db2", "DB2Handler", False)
|
srvr.AddHandler("/db2", "DB2Handler", False)
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ ModuleBreakpoints6=
|
|||||||
ModuleBreakpoints7=
|
ModuleBreakpoints7=
|
||||||
ModuleBreakpoints8=
|
ModuleBreakpoints8=
|
||||||
ModuleClosedNodes0=
|
ModuleClosedNodes0=
|
||||||
ModuleClosedNodes1=9,10,11,12,13,14,15
|
ModuleClosedNodes1=
|
||||||
ModuleClosedNodes2=9,10,11,12,13,14,15
|
ModuleClosedNodes2=
|
||||||
ModuleClosedNodes3=8,9,10,11,12,13,14,15
|
ModuleClosedNodes3=
|
||||||
ModuleClosedNodes4=8,9,10,11,12,13,14,15
|
ModuleClosedNodes4=
|
||||||
ModuleClosedNodes5=
|
ModuleClosedNodes5=
|
||||||
ModuleClosedNodes6=
|
ModuleClosedNodes6=
|
||||||
ModuleClosedNodes7=
|
ModuleClosedNodes7=
|
||||||
ModuleClosedNodes8=
|
ModuleClosedNodes8=
|
||||||
NavigationStack=RDCConnector,Class_Globals,4,0,RDCConnector,GetConnection,60,0,RDCConnector,LoadConfigMap,39,0,RDCConnector,Initialize,19,6,DB1Handler,ExecuteBatch,145,0,DB1Handler,Handle,17,0,RDCConnector,GetCommand,52,6,RDCConnector,LoadSQLCommands,66,6,Main,AppStart,28,6,Main,Process_Globals,14,0
|
NavigationStack=RDCConnector,LoadSQLCommands,120,6,RDCConnector,Initialize,21,6,Main,Process_Globals,28,0,DB1Handler,Class_Globals,8,0,DB1Handler,ReadList,312,0,Main,AppStart,81,6,DB2Handler,ReadList,312,0,DB3Handler,Class_Globals,11,0,DB3Handler,ReadList,312,0,DB3Handler,ReadBytesFully,277,0,DB4Handler,ReadList,312,0
|
||||||
SelectedBuild=0
|
SelectedBuild=0
|
||||||
VisibleModules=1,2,3,4,7,6,8
|
VisibleModules=1,2,3,4,7,6,8
|
||||||
|
|||||||
Reference in New Issue
Block a user