p6spy, create a new log file (with timestamp) at each start - java

title say it everything. I want to log my sql queries but the problem is, at each program restart it append query in same file because I'm specifying the same in my spy.properties file:
driverlist=com.mysql.cj.jdbc.Driver
dateformat=yyyy-MM-dd HH:mm:ss.SSSS
appender=com.p6spy.engine.spy.appender.FileLogger
logfile=C:\\Users\\manis\\Documents\\log\\dblog\\spy.log
logMessageFormat=com.p6spy.engine.spy.appender.SingleLineFormat
I want log file to have name something like this: spy_TIMESTAMP.log
I m using JDBC for db connection.

P6Spy does not support that functionality out of the box, but one thing you could do is to override values from spy.properties passing system properties -Dp6spy.config.logfile=myuniquefile.log or from the code:
System.setProperty("p6spy.config.logfile", String.format("C:\\Users\\manis\\Documents\\log\\dblog\\spy-%s.log", System.currentTimeMillis()));
but it should happen before JDBC driver initialisation.

Related

How to associate a guacamole recording file with a historical connection record

I am trying to redevelop guacamole.
I want to modify the source code of guacamole-client so that the screen file name can contain information such as user name, history connection id, etc., not just a fixed file name.
Can you tell me which part of the source code to modify, thank you
My problem has been solved.
I can use dynamic parameters when defining connection parameters
http://guacamole.apache.org/doc/gug/configuring-guacamole.html#parameter-tokens
"For example, if you set the connection parameter for the recording name to "potato-${GUAC_USERNAME}", the name of the recording will vary by the user accessing it. If you access it as "guacadmin", the recording is saved as "potato-guacadmin". All connection parameters can make use of this."--mike jumper
I think I can uniquely locate a session by adding a username and begin_time to the recording file name.

WrongClassExceptionObject:object with id:22 was not of the specified subclass ,only for new entries.old entries are working fine

I an using Ejb,Spring+hibernates in my application.
My application fetches a row from DB and based on its discriminator column value(entry1,entry2,entry3...) it connects to the JavaClass file which is marked in the tag of my tablename.hbm.xml file and code gets executed.
All my old code is working fine,
I have added a new.java file ,and when i tried to add a new entry to the tablename.hbm.xml file i am facing the below error.
org.springframework.orm.hibernate.HibernateobjectRetrivalFailureException:
object with id:22 was not of the specified subclass:(path of table1 related class)(Discriminator :entry1)
nested exception is net.sf.hibernate.WrongClassException : Object with id:22 was not of the specified subclass:(path of table1 related class)(Discriminator :entry1)
There are no duplicates in my table neither any space issues.
none of my new entires are getting executed.Is it due to my .hbm.xml file not getting refreshed everytime.please let me know for any suggestions.
Simply, add to project file properties following:
spring.jpa.properties.hibernate.discriminator.ignore_explicit_for_joined=true
It is works for me.

ThriftSecurityException (user:root, code:BAD_CREDENTIALS)

When I try to connect to accumulo from a java client, it is failing. I am using the 'root' user but have changed the password. I debugged my code, it is in fact getting the correct user name and password, the same I one I use to log into the shell with.
I read on some other sites that I have to set 'trace.user' and 'trace.password' in my accumulo-site.xml file, so I did that and restarted accumulo. Unfortunately it did not change a thing.
When I try to connect from java, these are the important lines from the stack:
Caused by: org.apache.accumulo.core.client.AccumuloSecurityException: Error BAD_CREDENTIALS for user root - Username or Password is Invalid
Caused by: ThriftSecurityException(user:root, code:BAD_CREDENTIALS)
From my accumulo console, I see this:
08 15:44:06,0544 tserver:michael-GA-890GPA-UD3H 4
ERROR
ThriftSecurityException(user:root, code:BAD_CREDENTIALS)
When I look through my accumulo logs I just see the same exception and its stack getting printed every second that goes by.
I went looking through the accumulo manual and couldn't find anything that I'm missing. A google search and SO search also did not help me.
Would somebody please tell me what I'm doing wrong?
Depending on the version you're using, you may also have trace.token.property.password defined in accumulo-site.xml which is the replacement for trace.password. >=1.6.0 introduced the trace.token.property.password property. If both that property and trace.password are present in the configuration, trace.token.property.password will take precedence over trace.password.
Look at the $ACCUMULO_LOG_DIR/tracer_$hostname.debug.log file, you'll likely have numerous exceptions in there.
The "proper" way (read as: how you'd want to do it in a production environment) to configure the tracer is to create the 'trace' table as 'root', create a 'trace' user, and give the 'trace' user READ, WRITE and ALTER_TABLE permissions on the 'trace' table. Then, update trace.user and trace.token.property.password in accumulo-site.xml.
Not sure if you still want the solution or not, what helped me is changing the value of trace.token.property.password to the correct password, i.e., the value of instance.secret for the trace.user 'root' in accumulo-site.xml file.
Or you could open the acccumulo shell using the 'root' user and create a new user inside the shell and then update the values of both the trace user and it's current password.

How to configure logging of insert statements using pgAdmin?

I want to use pgAdmin to configure to log all sql insert statements. But how?
I found the Backend Configuration Editor and enabled log_statement=all. But how can I control the file to that the log statements are written? (eg: c\logs.txt)
log_destination = 'stderr,csvlog'
log_statement = 'all'
#see C:\Program Files\PostgreSQL\9.3\data\pg_log
See the manual. You probably want to set log_directory and log_filename.
You cannot set individual log destinations for particular categories of log line - say, log statements to one file, other logs to another file. This would be a nice feature; if you have time, consider raising the idea on pgsql-hackers and after discussion submitting a suitable patch.
Most people use csvlog, or use text logs with a log_line_prefix set, then filter the logs with simple tools like grep to extract the desired information.
For statement data collection, also have a look at the pg_stat_statements extension.

How to Send a File Path to mysql table

I tired to send this file path
"C:\\Users\\Tesh\\Desktop\\Image - Copy.jpg";
but its show like this on mysql database
C:UsersTeshDesktopImage - Copy.jpg"
How Can i Fix this
Can you show us more of your File code so that we can help you? The double backslash (like you've shown) in Java should work, so it's probably something else.
Also, could you try:
"C:\\\\Users\\\\Tesh\\\\Desktop\\\\Image - Copy.jpg";
or preferably as per #Azad's suggestion:
"C:/Users/Tesh/Desktop/Image - Copy.jpg";

Categories

Resources