I'm creating a Logging service for the Firebird database.
I was using MON$REMOTE_PROCESS
to get through where the change was made. But it does not recognize .jar
.
When I query: SELECT MON$REMOTE_OS_USER, mon$attachment_id, MON$REMOTE_PROCESS FROM mon$attachments WHERE mon$attachment_id = current_connection
, in column MON$REMOTE_PROCESS
it returns null and when done through files .exe
it returns correctly.
Can this be a limitation of the bank or do I have to do something in the program to recognize it?
If necessary, it follows a small graphical interface and a test class:
Class:
package NewClass;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Conexao {
public static void main(String args[]) throws IOException {
Connection con;
Statement stm = null;
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");//DRIVER UTILIZADO
con = DriverManager.getConnection(
"jdbc:firebirdsql:localhost:C:\Bancos LOG\LOG.FDB?lc_ctype=WIN1252",
"SYSDBA",
"masterkey");
stm = con.createStatement();
} catch (ClassNotFoundException | SQLException e) {
System.out.println(e.getMessage());
}
try {
String query = "SELECT MON$REMOTE_OS_USER, mon$attachment_id, MON$REMOTE_PROCESS FROM mon$attachments WHERE mon$attachment_id = current_connection";
ResultSet rs = stm.executeQuery(query);
rs.next();
System.out.println(rs.getString("MON$REMOTE_OS_USER"));
System.out.println(rs.getString("mon$attachment_id"));
System.out.println(rs.getString("MON$REMOTE_PROCESS"));
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
}
Return:
Interface:
packageNewClass;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;publicclassNewJFrameextendsjavax.swing.JFrame{publicNewJFrame(){initComponents();Connectioncon;Statementstm=null;try{Class.forName("org.firebirdsql.jdbc.FBDriver");//DRIVER UTILIZADO
con = DriverManager.getConnection(
"jdbc:firebirdsql:localhost:C:\Bancos LOG\LOG.FDB?lc_ctype=WIN1252",
"SYSDBA",
"masterkey");
stm = con.createStatement();
} catch (ClassNotFoundException | SQLException e) {
System.out.println(e.getMessage());
}
try {
String query = "SELECT MON$REMOTE_OS_USER, mon$attachment_id, MON$REMOTE_PROCESS FROM mon$attachments WHERE mon$attachment_id = current_connection";
ResultSet rs = stm.executeQuery(query);
rs.next();
jLabel1.setText(rs.getString("MON$REMOTE_OS_USER"));
jLabel2.setText(rs.getString("mon$attachment_id"));
jLabel3.setText(rs.getString("MON$REMOTE_PROCESS"));
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("jLabel1");
jLabel2.setText("jLabel2");
jLabel3.setText("jLabel3");
jLabel4.setText("jLabel4");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(43, 43, 43)
.addComponent(jLabel2))
.addGroup(layout.createSequentialGroup()
.addGap(109, 109, 109)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel1)))
.addGroup(layout.createSequentialGroup()
.addGap(53, 53, 53)
.addComponent(jLabel4)))
.addContainerGap(45, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(36, 36, 36)
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addComponent(jLabel3)
.addGap(18, 18, 18)
.addComponent(jLabel4)
.addContainerGap(35, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
// End of variables declaration
}
Return: