I'm using Hibernate 4.3.5-Final for my Java Swing application and I do many UDPATE, INSERT and DELETE with it (in HQL or with Criteria).
Now, what I'm trying to do is to export a SQL script of all modifications done on my database but I don't know how to do that. This script need to contain only the modifications (and not the creation of the tables) and put them on a .sql file (exported file path will be chosen by the user)
Do you have any ideas that can solve my problem ?
Thank you in advance !
[Edit] : Some forums talk about p6spy, can it answer to my problem ?
p6spy should help here.
In general, following should do the job for you:
enable p6spy in your app (see official docs: http://p6spy.github.io/p6spy/)
afterwards you have basically 2 options:
use provided: BatchFileLogger, enabling it via: appender=com.p6spy.engine.spy.appender.BatchFileLogger in spy.properties (it's however undocumented yet, see: https://github.com/p6spy/p6spy/issues/119)
OR
implement custom com.p6spy.engine.spy.appender.MessageFormattingStrategy, that would be returning sql only (see: https://stackoverflow.com/a/23521623/1581069 for idea on implementation) and configure it in spy.properties via: logMessageFormat=FooFormat
set sqlexpression to match the queries you need - restricting CREATE/ALTER/... TABLE/SEQUENCE/... (see official docs: http://p6spy.github.io/p6spy/2.0/configandusage.html)
still there are some tricky points, like:
databaseDialectDateFormat property (to be able to kind of replay the output without modifications). For inspiration for some of the common databases, see the unit tests of p6spy itself: https://github.com/p6spy/p6spy/tree/master/src/test/resources/com/p6spy/engine/spy
Related
Regulations breakthrough! Due to major issues with recycling in XPages I got green light to install and use OpenNTF's Domino API now to leave a lot of recycling of Notes objects to ODA.
But what should I consider to change in code?
Besides creation of database object:
Database db = Utils.getSession().getDatabase("", "file.nsf");
Session sess = Factory.getSession(SessionType.CURRENT);
Database db = sess.getDatabase("", "file.nsf", true);
I noticed I saw code examples that stated SessionType.NATIVE. What is the difference?
I notice an additional parameter in sess.getDatabase("", "file.nsf", true). What is that for?
I also wonder what to do with all the exception handling that I have in my current code. Can I keep this or should I remove this?
What about logging for exceptions, do they appear automagically in openlog or not? Or how should I setup use of openlog?
Nowadays I use a different OpenNTF addon for use of OpenLog https://www.openntf.org/main.nsf/project.xsp?r=project/XPages%20OpenLog%20Logger . Can I remove this then?
I am looking for an example application for code but I have not found any yet. Perhaps you know a good source?
Thank you in advance for your guidance!
SessionType.NATIVE is used to run as the server. For the last few years I never used SessionAsSigner, only SessionType.NATIVE.
XPages OpenLog logger was incorporated into ODA. There may be different package names to import, but there are no differences in functionality. As I made changes to XPages OpenLog Logger, the same changes were made in ODA.
The demo app is available at http://paulswithers.me.uk/odaDemoApp and includes some documentation, including getting a database. You basically just need a single parameter and, if the database doesn’t exist, you get null returned, as would be normal for a Java method - no need to check if it’s
In the zipfile of the OpenNTF Domino API there is an apidoc folder this contains javadoc for the api.
I have a particularly tricky situation here. I am supporting an java based packaged web application that runs on JBoss. The application is a packaged application so I don't really have access to any code or know how the code was developed.
What I am trying to find out is what the JDBC fetchSize is being set to. I don't know where it is being set, meaning at the ResultSet level or Statement level etc..
Here is what I have tried so far:
1) I tried to configure tracing for the JDBC driver by downloading the ojdbc_g.jar file from Oracle and following the instructions that they provided. Unfortunately, in those instructions, it states that I need to add this jar file to the CLASSPATH and I am not sure where that is being set in this application. Needless to say, this path was not fruitful, as I was never able to successfully get a trace file output.
2) I tried using WireShark to capture all TNS packets to see if I could find it out that way, and this again was fruitless because at that level, it is next to impossible to actually find how many rows are being passed each time. There are so many other dependencies there, and I was unable to get the info I am after.
3) The last thing I tried was configuring a database side trace of SQL Net calls to the database, but I am not sure whether I have to do this in the sqlnet.ora file or if I have to trace the listener.
This is where I am stuck now. Again, all I want to do is find out what the application's JDBC fetchSize is being set (if its even being set at all). I know that this can impact the performance of the application so that's why I want to find it.
Any guidance is appreciated.
Thanks.
unpack the jar file, try grepping for fetchSize in the class files, this will give you the class file. Then disassemble or decompile, or debug to see what it is set to.
In SimpleORM (a JAVA ORM library) examples, I see a code like:
java.sql.DriverManager.getConnection("jdbc:hsqldb:hsqlTempFiles;shutdown=true;", "sa", "")
I am not able to understand the meaning of hsqlTempFiles in above. My basic understanding of hsqldb consists of file/mem/res/hsql based access modes. In SimpleORM code archive, I do see a file named hsqlTempFiles.properties and hsqlTempFiles.script.
Is this an older way to refer to file based hsqldb databases?
The part after hsqldb: is the name of the database to connect to. Specifying the name of the file without file: may just be legacy or backward-compatible logic.
I have some pojos, which are mapped to a tables in database.
When I deploy my code into performance tuning environment, I receive bunch of org.hibernate.MappingException due to $performasure_j2eeInfo is added to them by PerformaSure tool.
Is there a way, I can configure my hibernate context file, so this field mapping will ignore mapping error?
SOLVED:
PerformaSure support advised me to put a specific configuration key, to show my pojos to PS and put them in ignored state. I don't remember a correct solution now, but you can find it somewhere online
I've been able to get around the issue by modifying the instrumentation.config file under the /config/agent-orderride directory.
Edit the SafeModeClasses entry in that file to include a list of specific classes or packages.
SafeModeClasses = ClassList(
include com\.mycompany\.package\..*\.Foo\,
include com\.mycompany\.otherpackage\..*\./
);
Check out page 89 of the documentation here:
http://edocs.quest.com/foglight/558/files/CartridgeForJavaEE_Install.pdf
I'm assuming I need to use Connector\J and JDBC to achieve this, but I can't seem to 'install' Connector\J using the CLASSPATH thing. How do I do that ? I use the IntelliJ IDE if thats relevant.
I'm looking for a way to talk to a mysql database and execute and print out a few basic queries but I'm not getting anywhere because I can't even talk to the database.
Any help is appreciated.
You might follow an example such as this one:
http://www.kitebird.com/articles/jdbc.html
But, you might want to consider using Hibernate unless you're doing only a couple basic queries.
See Using MySQL with Java -- the first link from Google.
I like this tutorial because it's very detailed and thorough. Pretty much every step from downloading and installing MySQL and Connector/J to writing and running queries is covered.
Which version of IntelliJ?
You need to add the MySQL Connector-J JAR to your project dependencies.
Open your IntelliJ settings (the "wrench" in the top menu bar), go to "Libraries", click on "Attach Classes", and add the MySQL Connector-J JAR that you downloaded above. That puts it in your CLASSPATH.
If you still have problems, it means you don't have the driver class name right. It should be com.mysql.jdbc.Driver.