GithubHelp home page GithubHelp logo

shandy-db2's Introduction


Golang - Ibm db2


Table of Contents
  1. About The Project
  2. Getting Started
  3. License
  4. Contact
  5. Acknowledgements

About The Project

This system is using for testing Golang connection with Ibm db2 database, which ibm db2 database installed on docker.

Built With

This section we explain what is backend is develop with

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

  • First you need to install Golang

  • After that check the installation and Golang version it must be above than 1.11 because we need the Golang Modules

    > go version
    go version go1.16.3 darwin/amd64
  • Create docker volume

    docker volume create ibm-data
  • Install db2 on docker
    docker run -d --restart=always --name=ibm-exp --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INST1_PASSWORD=password -e DBNAME=testdb -v ibm-data:/database ibmcom/db2
  • Check the logs
    ❯ docker logs ibm-exp | grep "Setup"

            (*) Setup has completed.


        _________________________________________________________________________

                            _____   DB2 Service Tools   _____

                                    I      B      M

                                    db2updv115

        This tool is a service utility designed to update a DB2 Version 11.5
        database to the current fix pack level.

        _________________________________________________________________________
  • Enter the docker console for the db2 instance
    ❯ docker exec -it ibm-exp bash -c "su - db2inst1"
    Last login: Sun Aug  8 15:12:47 UTC 2021 on pts/0
    [db2inst1@da30f52444ce ~]$
  • Check 1
    [db2inst1@da30f52444ce ~]$ db2 get dbm cfg|grep SVCENAME
    TCP/IP Service name                          (SVCENAME) = db2c_db2inst1
    SSL service name                         (SSL_SVCENAME) =
  • Check 2
    [db2inst1@da30f52444ce ~]$ cat /etc/services | grep db2c_db2inst1
    db2c_db2inst1      50000/tcp
    db2c_db2inst1_ssl  50001/tcp
    [db2inst1@da30f52444ce ~]$
  • Check 3
    [db2inst1@da30f52444ce ~]$ db2 list db directory

    System Database Directory

    Number of entries in the directory = 1

    Database 1 entry:

    Database alias                       = TESTDB
    Database name                        = TESTDB
    Local database directory             = /database/data
    Database release level               = 15.00
    Comment                              =
    Directory entry type                 = Indirect
    Catalog database partition number    = 0
    Alternate server hostname            =
    Alternate server port number         =

    [db2inst1@da30f52444ce ~]$
  • Check 4 - Connect to the database from docker console
    [db2inst1@da30f52444ce ~]$ db2 connect to testdb

            Database Connection Information

        Database server        = DB2/LINUXX8664 11.5.6.0
        SQL authorization ID   = DB2INST1
        Local database alias   = TESTDB

        [db2inst1@da30f52444ce ~]$

Installation

  • Install Db2 Driver for my Mac OS
   ❯ go get -d github.com/ibmdb/go_ibm_db
  • Download the Db2 Driver from ibm

  • Add the Db2 installation path at the bottom, and make sure the dspath is correct

    ❯ nano ~/.zshrc
    # ibm db2 driver
    export DB2HOME=/Applications/dsdriver
    export CGO_CFLAGS=-I$DB2HOME/include
    export CGO_LDFLAGS=-L$DB2HOME/lib
    export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Applications/dsdriver/lib
    
    ❯ source  ~/.zshrc
  • Done, try run the program
    ❯ go run main.go
    NIM    NAMA   
    -------------------------------------
    1  satu   

License

MIT.

Contact

Dedy Styawan - dedy.styawan - [email protected]

Shandy Siswandi - shandysiswandi - [email protected]

Acknowledgements

shandy-db2's People

Contributors

jadahbakar 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.