Coder Social home page Coder Social logo

mybatis-cockroach-demo's Introduction

Demo of MyBatis and Cockroach DB

This demo is fashioned off of the Cockroach DB demos here: https://www.cockroachlabs.com/docs/v19.2/build-a-java-app-with-cockroachdb.html

The demo shows how to use MyBatis to interact with CockroachDB. The demo is a Spring Boot application and uses the MyBatis Spring Integration to make things easy to configure.

How To Run the Demo

  1. Install cockroach: brew install cockroachdb/tap/cockroach

  2. Start a Cockroach cluster: cockroach start --insecure

    You could also run CockroachDB constantly in the background with brew services start cockroachdb/tap/cockroach

  3. Connect to cockroach shell: cockroach sql --insecure

    If you are running CockroachDB from the command line, you will need to do this in a separate terminal session.

  4. Run SQL commands to create the user and database...

    CREATE USER IF NOT EXISTS maxroach;
    CREATE DATABASE bank;
    GRANT ALL ON DATABASE bank TO maxroach;
    \q
  5. The application is configured to connect to CockroachDB running locally at the default port (26257). If you have CockroachDB running elsewhere, modify the values in src/main/resources/application.yml appropriately.

  6. Run the application: ./gradlew bootRun - you should see the Spring app start, then several messages about database updates. Note that this requires CockroachDB to be running and available as configured in src/main/resources/application.yml

  7. You can also run the integration tests with ./gradlew test. This will start CockroachDB in a Docker container and run the tests against that instance. This requires you to have Docker installed, but you do not need to install CockroachDB manually.

mybatis-cockroach-demo's People

Contributors

jeffgbutler avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.