-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: password in plain text
PostPosted: Sun Mar 26, 2006 2:04 pm 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.1.7c
when i run my app's jar from command line i notice my database info (user + pass) appear in plain text on console!
i raised all my logging levels but without result

how can i stop this?

TiA


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 26, 2006 11:01 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Is it being printed out in some logging line? Or just a println? I've never seen it printed out in any of my apps, so it might be something specific to your application. Is there tracing info on the same line? (Something like "[ INFO] <name of file>:<lineno> - SQL user: <user> SQL pwd: <pwd>" maybe?) Perhaps you can use that information to figure out why it's being printed out. If there's no info like that, then it's jut a println or similar, and you'll have to track it down in your application code.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 5:44 am 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
tenwit: thanks for your answer

here's a fraction of what appears in command line when i use:
java.exe -jar myJar.jar
Quote:
27/Mar/2006 10:27:38 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/myDatabase
27/Mar/2006 10:27:38 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=myUser, password=myPass}
27/Mar/2006 10:27:38 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup


My app is a stand alone (swing) app - no web.

i tried
- raising log4j.properties levels higher,
- coment out everything in log4j.properties,
- make the jar without log4j and even
- raise log levels in my java5 installĀ“s properties logging file...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 5:52 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
It's definitely a log4j log.. unless you've bound the apache commons log interface to some other logger. Assuming that you haven't, put this line somewhere in your log4j.properties:
Code:
log4j.logger.net.sf.hibernate.connection=ERROR


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 6:25 pm 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
thanks again, tenwit
your suggestion didnt work...
here's my log4j.properties:
Code:
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

log4j.rootLogger=warn, stdout
log4j.logger.net=warn
log4j.logger.net.sf.hibernate=warn
log4j.logger.net.sf.hibernate.connection=ERROR
### log just the SQL
#log4j.logger.net.sf.hibernate.SQL=debug

### log JDBC bind parameters ###
log4j.logger.net.sf.hibernate.type=warn

### log schema export/update ###
log4j.logger.net.sf.hibernate.tool.hbm2ddl=debug

### log cache activity ###
#log4j.logger.net.sf.hibernate.cache=debug

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.net.sf.hibernate.connection.DriverManagerConnectionProvider=trace

all like before...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 6:33 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Well that should work, unless someone has redefined info to be higher level than warn: hardly likely. Is it possible that a different properties file is being used? Try putting in a syntax error into your file and see if you get a log4j warning on startup. If you don't see one, then a different file is being used. Check that the version you're editing in your source tree is being copied to your classpath (if appropriate).

You might also doublecheck net.sf.hibernate.connection.DriverManagerConnectionProvider to ensure that nothing odd has been done there.. maybe someone put in a println that looks like a log statement, or someone set in a hardcoded level into that logger.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 7:27 pm 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
here's what i did so far:
- made a search for al log4j inside my workspace
- deleted them all
- copied a new one from hibernate dist
- when run from eclipse eclipse's console wrote like my console, with all that info statments
- raised to warn - nothing printed
- made a jar and all was like before
- finally went to
C:\Programas\Java\jdk1.5.0_06\jre\lib and edited the logging.properties - and got it working!!!

i checked inside my new jar and log4j.properties is there, but for some misterious reason doesnt work...
my log4j.properties is side by side with hibernate.cfg.xml - and if this one is seen, the the log4j should also be seen...
BTW, thanks for keeping helping me


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 7:38 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
It won't be seen if another log4j.properties is found first. As I understand it, log4j checks the current working directory first, then it goes through your classpath, and uses the first one it finds. So if your jar is at the end of your classpath (for security reasons, people often set "." as the last item in their classpath, and jars in the current working directory will be found at that point), then some other file might be found first. And if it contains a line like "log4j.logger.net=DEBUG", then everything in hibernate would be output at debug level..


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 7:48 pm 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
now i did get it
for some reason, log4j.jar was not in my jar, but just referenced from eclipse; the minute i fisically added it to eclipse and made a new jar, all works ok, with logging properties file from java5 set to info again
thanks again!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.