npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bcray-jdbc-fork

v0.13.4

Published

use jdbc from node

Downloads

1

Readme

@naxmefy/jdbc

small wrapper to work with jdbc in node.

npm version

Build Status Coverage Status

prerequisites

node-java

$ npm install --save java

HINT

node-java installation can fail on windows (i never got it work on windows).

I used docker on windows to get it working.

You can find my example docker image on docker hub at https://hub.docker.com/r/naxmefy/node-java/ or https://github.com/naxmefy/docker-node-java

OPTIONAL: node-java-maven

$ npm install --save node-java-maven

installation

$ npm install --save @naxmefy/jdbc

usage

setup jdbc driver inside package.json

{
    "name": "myapp",
    "version": "0.0.0",
    "private": true,
    "java": {
      "dependencies": [
        {
          "groupId": "com.h2database",
          "artifactId": "h2",
          "version": "1.4.195"
        }
      ]
    },
    "dependencies": {
      "@naxmefy/jdbc": "^0.1.0",
      "java": "^0.8.0",
      "node-java-maven": "^0.0.12"
    }
}

in your main file (js)

const JDBC = require('@naxmefy/jdbc').JDBC
const myDatabase = new JDBC({
  className: 'any.jdbc.Driver',
  url: 'jdbc:to:any.db',
  username: 'foo',
  password: 'bar'
})

myDatabase.createStatement()
  .then(statement => {
    return statement.executeQuery('SELECT * FROM FOO')
  })
  .then(resultSet => {
      const arrayOfResults = resultSet.fetchAllResults()
      arrayOfResults.forEach(result => {
          console.log(result)
      })
  })

or with typescript (types included)

import {JDBC, ResultSet, Statement} from '@naxmefy/jdbc'
const myDatabase = new JDBC({
  className: 'any.jdbc.Driver',
  url: 'jdbc:to:any.db',
  username: 'foo',
  password: 'bar'
})

myDatabase.createStatement()
  .then((statement: Statement) => {
    return statement.executeQuery('SELECT * FROM FOO')
  })
  .then((resultSet: ResultSet) => {
      const arrayOfResults = resultSet.fetchAllResults()
      arrayOfResults.forEach(result => {
          console.log(result)
      })
  })

usage with Docker

HINT

The following docker config contains proxy config too. Maybe you do not need it.

example Dockerfile

FROM naxmefy/node-java

WORKDIR /usr/app

COPY package.json .
RUN npm config set proxy $HTTP_PROXY
RUN npm config set https-proxy $HTTPS_PROXY
RUN npm install --quiet

COPY . .

example docker-compose.yml

version: '2'
services:
  web:
    build:
      context: .
      args:
        - http_proxy
        - https_proxy
        - no_proxy
        - HTTP_PROXY
        - HTTPS_PROXY
        - NO_PROXY
    command: npm start
    volumes:
      - .:/usr/app/
      - /usr/app/node_modules
    ports:
      - "3000:3000"
    links:
      - postgres
    environment:
      NODE_ENV: development
      DEBUG: @naxmefy/jdbc
  postgres:
    image: postgres
    environment:
      POSTGRES_USER: pguser
      POSTGRES_PASSWORD: pgpass
      POSTGRES_DB: pgdb
    ports:
      - "5432:5432"

example java maven config

{
  "java": {
    "dependencies": [
      {
        "groupId": "org.postgresql",
        "artifactId": "postgresql",
        "version": "42.1.1"
      }
    ]
  }
}

example jdbc instantiation

const myPostgresDB = new JDBC({
  className: 'org.postgresql.Driver',
  url: 'jdbc:postgresql://postgres:5432/pgdb',
  username: 'pguser',
  password: 'pgpass'
})

Contributing

  • open issues for bugs or whatever
  • fork repo, make change, start pull request

License

MIT