Skip to main content

Posts

Showing posts with the label SQL

IllegalStateException from Mongo storage plugin in Apache Drill

Apache Drill ( https://drill.apache.org/ ) is an Open Source framework that supports data-intensive distributed applications for interactive analysis of large scale datasets. It supports several kinds of filesystems and NoSQL databases, including HDFS and MongoDB. In this short post I want to show an exception you could deal with if your Drill installation has the MongoDB storage plugin enabled. If suddenly, after more than 24 of uptime, any SQL query (not only those against a MongoDB database) issued through Drill throw the following exception: SYSTEM ERROR: IllegalStateException: state should be: open [Error Id: 57a02508-1920-4360-a111-c2a55a7af15c on hostname:31010]] this should be related to a connection cache that expires and isn't automatically reset. This issue affects in particular the latest release (1.1.0) of Drill and it is still marked as unresolved at the time of this post writing ( https://issues.apache.org/jira/browse/DRILL-3522 ), but there is a patch available...

Dance into the Groovy

Groovy ( http://groovy.codehaus.org/ ) is an Object Oriented scripting language for the Java platform. It is dinamically compiled to bytecode for the Java Virtual Machine. It can use and interoperate with any Java class and library (any, not only the ones provided by the JDK) and it has a Java-like syntax: this way its learning curve for a Java depeloper is almost close to zero. Groovy is very powerful and can help in different areas: in some future post I will show and explain better its benefits. In this one I want to show you just a concrete example of use from me in the past. Many times we had to deal with the move of hundreds of Oracle schemas from an envirnoment to another (dev, test, QA, production) or to migrate them from an Oracle release to another. Every time the DBAs regularly forgot to set up the DB links for the new environment. This generated errors that couldn't often be identified quickly. In order to avoid this I wrote a set of Groovy scripts to check the sanity o...

jOOQ: code generation in Eclipse

jOOQ allows code generation from a database schema through ANT tasks, Maven and shell command tools. But if you're working with Eclipse it's easier to create a new Run Configuration to perform this operation. First of all you have to write the usual XML configuration file for the code generation starting from the database: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd">   <jdbc>     <driver>oracle.jdbc.driver.OracleDriver</driver>     <url>jdbc:oracle:thin:@dbhost:1700:DBSID</url>     <user>DB_FTRS</user>     <password>password</password>   </jdbc>   <generator>     <name>org.jooq.util.DefaultGenerator</name>     <database>       <name>org.jooq.util.oracle.OracleDatabase</name>     ...

jOOQ

jOOQ (Java Object Oriented Querying,  http://www.jooq.org/ ) is an Open Source library that provides a DSL to use SQL as it were natively supported by Java and treated in a object oriented way.  A SQL statement like this: SELECT * FROM BOOK WHERE PUBLISHED_IN = 2011 ORDER BY TITLE in jOOQ DSL becomes: create . selectFrom ( BOOK ) . where ( PUBLISHED_IN . equal ( 2011 )) . orderBy ( TITLE ) But jOOQ isn't just a DSL. It provides also other important features: Code Generation Active records Typesafe SQL SQL standard Vendor-specific feature support and supports the latest versions of the major database vendors.  jOOQ could be a powerful option to Hibernate or JPA. Tomorrow I am going to publish a post about the integration between Spring and jOOQ. Stay tuned!