mirror of
https://github.com/KeymonSoft/jRDC-Multi.git
synced 2026-04-17 21:06:24 +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:
@@ -23,34 +23,33 @@ End Sub
|
||||
Sub Handle(req As ServletRequest, resp As ServletResponse)
|
||||
Log("********************* DB1 ********************")
|
||||
Dim start As Long = DateTime.Now
|
||||
Dim q As String
|
||||
Dim q As String
|
||||
Dim in As InputStream = req.InputStream
|
||||
Dim method As String = req.GetParameter("method")
|
||||
Connector = Main.Connectors.Get("DB1")
|
||||
Dim con As SQL
|
||||
Try
|
||||
con = Connector.GetConnection("DB1")
|
||||
' con = Main.rdcConnectorDB1.GetConnection("")
|
||||
If method = "query2" Then
|
||||
q = ExecuteQuery2("DB1", con, in, resp)
|
||||
'#if VERSION1
|
||||
'#if VERSION1
|
||||
Else if method = "query" Then
|
||||
in = cs.WrapInputStream(in, "gzip")
|
||||
q = ExecuteQuery("DB1", con, in, resp)
|
||||
Else if method = "batch" Then
|
||||
in = cs.WrapInputStream(in, "gzip")
|
||||
q = ExecuteBatch("DB1", con, in, resp)
|
||||
'#end if
|
||||
'#end if
|
||||
Else if method = "batch2" Then
|
||||
q = ExecuteBatch2("DB1", con, in, resp)
|
||||
Else
|
||||
Log("Unknown method: " & method)
|
||||
resp.SendError(500, "unknown method")
|
||||
End If
|
||||
Catch
|
||||
Log(LastException)
|
||||
resp.SendError(500, LastException.Message)
|
||||
End Try
|
||||
Catch
|
||||
Log(LastException)
|
||||
resp.SendError(500, LastException.Message)
|
||||
End Try
|
||||
If con <> Null And con.IsInitialized Then con.Close
|
||||
Log($"Command: ${q}, took: ${DateTime.Now - start}ms, client=${req.RemoteAddress}"$)
|
||||
End Sub
|
||||
@@ -154,11 +153,11 @@ Private Sub ExecuteBatch(DB As String, con As SQL, in As InputStream, resp As Se
|
||||
WriteInt(r, out)
|
||||
Next
|
||||
out.Close
|
||||
Catch
|
||||
con.Rollback
|
||||
Log(LastException)
|
||||
resp.SendError(500, LastException.Message)
|
||||
End Try
|
||||
Catch
|
||||
con.Rollback
|
||||
Log(LastException)
|
||||
resp.SendError(500, LastException.Message)
|
||||
End Try
|
||||
Return $"batch (size=${numberOfStatements})"$
|
||||
End Sub
|
||||
|
||||
@@ -237,7 +236,7 @@ Private Sub WriteObject(o As Object, out As OutputStream)
|
||||
Else If GetType(o) = "[B" Then
|
||||
data = o
|
||||
out.WriteBytes(Array As Byte(T_BLOB), 0, 1)
|
||||
WriteInt(data.Length, out)
|
||||
WriteInt(data.Length, out)
|
||||
Else 'If o Is String Then (treat all other values as string)
|
||||
out.WriteBytes(Array As Byte(T_STRING), 0, 1)
|
||||
data = bc.StringToBytes(o, "UTF8")
|
||||
|
||||
@@ -30,7 +30,6 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
|
||||
Dim con As SQL
|
||||
Try
|
||||
con = Connector.GetConnection("DB2")
|
||||
' con = Main.rdcConnectorDB2.GetConnection("DB2")
|
||||
If method = "query2" Then
|
||||
q = ExecuteQuery2("DB2", con, in, resp)
|
||||
'#if VERSION1
|
||||
|
||||
@@ -29,7 +29,6 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
|
||||
Connector = Main.Connectors.Get("DB3")
|
||||
Dim con As SQL
|
||||
Try
|
||||
' con = Main.rdcConnectorDB3.GetConnection("DB3")
|
||||
con = Connector.GetConnection("DB3")
|
||||
If method = "query2" Then
|
||||
q = ExecuteQuery2("DB3", con, in, resp)
|
||||
|
||||
@@ -29,7 +29,6 @@ Sub Handle(req As ServletRequest, resp As ServletResponse)
|
||||
Connector = Main.Connectors.Get("DB4")
|
||||
Dim con As SQL
|
||||
Try
|
||||
' con = Main.rdcConnectorDB4.GetConnection("DB4")
|
||||
con = Connector.GetConnection("DB4")
|
||||
If method = "query2" Then
|
||||
q = ExecuteQuery2("DB4", con, in, resp)
|
||||
|
||||
@@ -17,12 +17,64 @@ 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
|
||||
If DB.EqualsIgnoreCase("DB1") Then DB = "" 'Esto para el config.properties por 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"))
|
||||
pool.Initialize(config.Get("DriverClass"), config.Get("JdbcUrl"), config.Get("User"), 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
|
||||
DebugQueries = True
|
||||
#else
|
||||
@@ -33,13 +85,6 @@ Public Sub Initialize(DB As String)
|
||||
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
|
||||
|
||||
@@ -28,7 +28,7 @@ Version=10
|
||||
#Region Project Attributes
|
||||
#CommandLineArgs:
|
||||
#MergeLibraries: True
|
||||
' VERSION 4.11.09
|
||||
' VERSION 4.11.14
|
||||
'###########################################################################################################
|
||||
'###################### 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
|
||||
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
|
||||
Type DBCommand (Name As String, Parameters() As Object)
|
||||
Type DBResult (Tag As Object, Columns As Map, Rows As List)
|
||||
@@ -65,7 +61,6 @@ Sub AppStart (Args() As String)
|
||||
srvr.Initialize("")
|
||||
Dim con As RDCConnector
|
||||
Connectors = srvr.CreateThreadSafeMap
|
||||
' commandsMap = srvr.CreateThreadSafeMap
|
||||
commandsMap.Initialize
|
||||
con.Initialize("DB1") 'Inicializamos el default de config.properties
|
||||
Connectors.Put("DB1", con)
|
||||
@@ -75,31 +70,28 @@ Sub AppStart (Args() As String)
|
||||
If cpFiles.Size > 0 Then
|
||||
Log(cpFiles)
|
||||
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
|
||||
con.Initialize("DB2")
|
||||
Connectors.Put("DB2", con)
|
||||
listaDeCP.Add("DB2")
|
||||
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
|
||||
con.Initialize("DB3")
|
||||
Connectors.Put("DB3", con)
|
||||
listaDeCP.Add("DB3")
|
||||
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")
|
||||
Connectors.Put("DB4", con)
|
||||
listaDeCP.Add("DB4")
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
' con.Initialize("DB1") 'Inicializamos el default de config.properties
|
||||
' Connectors.Put("DB1", con)
|
||||
' srvr.Port = con.serverPort
|
||||
srvr.AddHandler("/test", "TestHandler", False)
|
||||
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)
|
||||
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("/db2", "DB2Handler", False)
|
||||
|
||||
@@ -17,14 +17,14 @@ ModuleBreakpoints6=
|
||||
ModuleBreakpoints7=
|
||||
ModuleBreakpoints8=
|
||||
ModuleClosedNodes0=
|
||||
ModuleClosedNodes1=9,10,11,12,13,14,15
|
||||
ModuleClosedNodes2=9,10,11,12,13,14,15
|
||||
ModuleClosedNodes3=8,9,10,11,12,13,14,15
|
||||
ModuleClosedNodes4=8,9,10,11,12,13,14,15
|
||||
ModuleClosedNodes1=
|
||||
ModuleClosedNodes2=
|
||||
ModuleClosedNodes3=
|
||||
ModuleClosedNodes4=
|
||||
ModuleClosedNodes5=
|
||||
ModuleClosedNodes6=
|
||||
ModuleClosedNodes7=
|
||||
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
|
||||
VisibleModules=1,2,3,4,7,6,8
|
||||
|
||||
Reference in New Issue
Block a user