{"id":15284344,"url":"https://github.com/zhicwu/cassandra-jdbc-driver","last_synced_at":"2025-04-12T23:22:05.470Z","repository":{"id":34295670,"uuid":"38196213","full_name":"zhicwu/cassandra-jdbc-driver","owner":"zhicwu","description":"Cassandra JDBC driver that works with 2.x and above. It intends to provide better SQL compatibility over CQL, so that it works well with existing tools like SQuirreL SQL for SQL development, JMeter for stress testing, and Pentaho BI Suite for data processing.","archived":false,"fork":false,"pushed_at":"2019-02-19T06:47:19.000Z","size":1005,"stargazers_count":51,"open_issues_count":11,"forks_count":22,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-26T17:21:23.486Z","etag":null,"topics":["cassandra","driver","jdbc","jdbc-connector","jdbc-driver","kettle","pdi"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhicwu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-28T11:20:38.000Z","updated_at":"2024-03-31T14:16:22.000Z","dependencies_parsed_at":"2022-09-11T06:51:23.747Z","dependency_job_id":null,"html_url":"https://github.com/zhicwu/cassandra-jdbc-driver","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhicwu%2Fcassandra-jdbc-driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhicwu%2Fcassandra-jdbc-driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhicwu%2Fcassandra-jdbc-driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhicwu%2Fcassandra-jdbc-driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhicwu","download_url":"https://codeload.github.com/zhicwu/cassandra-jdbc-driver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248644187,"owners_count":21138565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cassandra","driver","jdbc","jdbc-connector","jdbc-driver","kettle","pdi"],"created_at":"2024-09-30T14:53:58.995Z","updated_at":"2025-04-12T23:22:05.451Z","avatar_url":"https://github.com/zhicwu.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JDBC Driver for Apache Cassandra\n\n[![Build Status](https://travis-ci.org/zhicwu/cassandra-jdbc-driver.svg?branch=master)](https://travis-ci.org/zhicwu/cassandra-jdbc-driver)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.zhicwu/cassandra-jdbc-driver/badge.svg)](https://search.maven.org/remote_content?g=com.github.zhicwu\u0026a=cassandra-jdbc-driver\u0026v=LATEST\u0026c=shaded)\n\nType 4 JDBC driver for Apache Cassandra. Building on top of [DataStax Java Driver](https://github.com/datastax/java-driver/)\nand [JSqlParser](https://github.com/JSQLParser/JSqlParser), it intends to provide better SQL compatibility over CQL,\nso that it works well with existing tools like [SQuirreL SQL](http://www.squirrelsql.org/) for SQL development,\n[JMeter](http://jmeter.apache.org) for stress testing, and [Pentaho BI Suite](http://community.pentaho.com/)\nfor data processing and reporting.\n\nYou may find this helpful if you came from RDBMS world and hoping to get your hands on Apache Cassandra right away.\nHaving said that, it is **NOT** recommended to use this for production but development and research. You should use\nDataStax Java Driver, Spark and maybe Presto if you want to do something serious.\n\nOK, you have been warned :) Now go ahead to download the latest driver and give it a shot!\n\n## Features\n\n* Implicit type conversion for ease of use\n```java\n...\n// set parameter\npreparedStatment.setString(index, \"13:30:54.234\"); // or setTime(index, new Time(1465536654234L))\n...\n// get query result\nresultSet.getTime(index); // or getString(index)\n...\n```\n\n* Instruct CQL statement through CQL comments(aka. magic comments)\n```cql\n/* please be aware that only single line comment begins with \"set\" can be recognized */\n-- set consistency_level = ALL; fetch_size = 10000;\n// set no_limit = true; read_timeout = 600;\nselect * from logs\n```\n\n* Limit unconstrained queries according to configuration\n```cql\n-- the following SQL will be translated to \"SELECT * FROM logs LIMIT 10000\"\n-- you may change the behavior via magic comments or config.yaml\nselect * from logs\n```\n\n* Improved SQL compatibility, for example: table alias, and more to come: group by, select into, insert select,\nfield expression, lucene filter(if you have [Stratio's Cassandra Lucene Index](https://github.com/Stratio/cassandra-lucene-index) installed)...\n```cql\n-- the following SQL will be translated into \"SELECT * FROM logs LIMIT 10000\"\nselect l.* from logs l\n```\n\n* Possibly support alternative Java driver, for example: [Netflix Astyanax](https://github.com/Netflix/astyanax)\n\n* Possibly support alternative storage (e.g. [HBase](http://hbase.apache.org/) just for fun)\n\n## Get Started\nBefore you start, please make sure you have JDK 7 or above - JDK 6 is not supported.\n\n#### Get the driver\nThe last release of the driver is available on Maven Central. You can install it in your application using\nthe following Maven dependency:\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.github.zhicwu\u003c/groupId\u003e\n\t\u003cartifactId\u003ecassandra-jdbc-driver\u003c/artifactId\u003e\n\t\u003cversion\u003e0.6.1\u003c/version\u003e\n\t\u003c!-- comment out the classifier if you don't need shaded jar --\u003e\n\t\u003cclassifier\u003eshaded\u003c/classifier\u003e\n\u003c/dependency\u003e\n```\nIf you can't use a dependency management tool, you can download the latest shaded jar from\n[here](http://central.maven.org/maven2/com/github/zhicwu/cassandra-jdbc-driver/).\n\nOptionally, if you want to build the driver on your own. You may follow the instructions below if you have both Git\nand Maven installed:\n```bash\n$ git clone https://github.com/zhicwu/cassandra-jdbc-driver\n$ cd cassandra-jdbc-driver\n$ mvn clean package\n$ ls -alF target/cassandra-jdbc-driver-*-shaded.jar\n```\n\n#### Say Hello to Cassandra\nThis is pretty much same as we did for any other database, except different driver and connection URL.\n```java\n...\n// Driver driver = new com.github.cassandra.jdbc.CassandraDriver();\nProperties props = new Properties();\nprops.setProperty(\"user\", \"cassandra\");\nprops.setProperty(\"password\", \"cassandra\");\n\n// \":datastax\" in the URL is optional, it suggests to use DataStax Java driver as the provider to connect to Cassandra\nConnection conn = DriverManager.getConnection(\"jdbc:c*:datastax://host1,host2/system_auth?consistencyLevel=ONE\", props);\n// change current keyspace from system_auth to system\nconn.setSchema(\"system\");\n\n// query peers table in current keyspace, by default the SQL below will be translated into the following CQL:\n// SELECT * FROM peers LIMIT 10000\n// Please be aware that the original SQL does not work in Cassandra as table alias is not supported\nResultSet rs = conn.createStatement().executeQuery(\"select p.* from peers p\");\nwhile (rs.next()) {\n...\n}\n...\n```\n\n## Configuration\n\n#### Driver Configuration\nDefault settings of this driver can be found in [config.yaml](src/main/resources/config.yaml). Besides changing it\nin the jar file, you may set system property \"cassandra.jdbc.driver.config\" to use your own config instead.\n```bash\n$ java -Dcassandra.jdbc.driver.config=/usr/local/private/new_config.yaml ...\n```\n\n#### Connection Properties\n![Connection Properties](../../raw/master/resources/images/connection_properties.png)\n\n#### Magic Comments\nTo set read timeout to 120 seconds just for a specific query, you can do it by adding a single line comment:\n```sql\n-- set read_timeout=120\nselect * from xyz\n```\nPlease notice that magic comments have to be started with \"-- set \" or \"// set \", and you can use semicolon as separator\nin one line for multiple instructions:\n```sql\n-- set read_timeout = 120; replace_null_value = true\n-- set no_limit = true\nselect * from xyz\n```\nAll supported instructions in magic comments are declared at\n[here](src/main/java/com/github/cassandra/jdbc/CassandraCqlStmtConfiguration.java).\n\n## HOWTOs\n\n#### SQuirrel SQL\n1. Configure Apache Cassandra driver\n    ![Configure Driver](../../raw/master/resources/images/configure_driver.png)\n2. Create a new alias using above driver\n    ![Configure Alias](../../raw/master/resources/images/configure_alias.png)\n3. Congratulations! You now can to connect to Cassandra\n    ![Query Trace](../../raw/master/resources/images/query_trace.png)\n4. To use magic comments, please use \"//\" instead of \"--\" as SQuirrel SQL will remove the latter automatically\nbefore sending the query to JDBC driver.\n\n#### JMeter\n1. Put the driver in $JMETER_HOME/lib directory\n2. Use JDBC Sampler to access Cassandra\n\n#### Pentaho Data Integration(aka. Kettle)\n1. Put the driver in $KETTLE_HOME/lib directory\n2. Create new connection to Cassandra\n3. Use TableInput / TableOutput steps to query / update Cassandra data\n4. You may want to add \"-- set replace_null_value = true\" to your query, as Kettle tries to use NULL value get meta data\n\n#### Pentaho BI Server\n1. Put the driver in $BISERVER_HOME/tomcat/lib directory\n2. Create new datasource pointing to Cassandra\n3. Use CDA to issue SQL to access Cassandra - Mondrian is not tested and is not supposed to work\n\n## Build\n```bash\n$ mvn -Prelease notice:generate\n$ mvn license:format\n$ mvn clean package\n```\n\n## TODOs\n- [x] ~~Remove CQL Parser to support JDK 7~~\n- [ ] UDT support and smooth type conversion\n- [ ] Multiple ResultSet support, especially when tracing turned on\n- [ ] Better SQL compatibility(e.g. SELECT INTO, GROUP BY and probably simple table joins and sub-queries)\n- [ ] (Basic)Mondrian support\n- [ ] More providers(and storage?)...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhicwu%2Fcassandra-jdbc-driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhicwu%2Fcassandra-jdbc-driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhicwu%2Fcassandra-jdbc-driver/lists"}