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

node-jdbc-firebird

v1.3.12

Published

This package is help to use jdbc connection

Downloads

912

Readme


Features

  • Simplified JDBC Usage: Provides an intuitive API to manage JDBC database connections, execute queries, and handle update statements, abstracting away low-level complexities.

  • Multiple Database Support: Seamlessly connect to different types of databases, including Hive, PostgreSQL, Tibero, and SQLite, with a unified interface.

  • Flexible Configuration: Easily configure database connections using either host, port, database name, username, and password or via custom JDBC connection with driver jars and connection URLs.

  • Connection Pooling: Benefit from built-in connection pooling support to efficiently manage and reuse database connections, enhancing application performance.

  • Query Execution: Execute custom SQL queries and retrieve results in a straightforward manner, enabling you to interact with your database effortlessly.

  • Database Structure Information: Retrieve comprehensive information about table and column structures using simple methods, enabling you to work with your database schema efficiently.

  • Data Manipulation: Perform essential data manipulation tasks such as counting rows, finding rows based on criteria, retrieving all rows from a table, and more.

  • Data Definition Language (DDL) Support: Execute DDL queries to manage the structure of your database, including creating and altering tables, views, and indexes.

Installation

To install the package, use the following command:

npm install --save node-jdbc-driver

Loading and configuring the module

You can initialize the JDBC driver using either CommonJS or ES6 syntax:

// CommonJS
const { default: JdbcDriver, ConnectionType } = require("node-jdbc-driver");

// ES6
import JdbcDriver, { ConnectionType } from 'node-jdbc-driver';

Common Usage

Below are some minimal usage examples demonstrating how to use the node-jdbc-driver package.

Connection Setup

For different types of databases, you need to provide specific connection details.

Available Connection types

ConnectionType.hive // for hive connection
ConnectionType.postgreSql // for postgreSql connection
ConnectionType.sqlite // for sqlite connection
ConnectionType.tibero // for tibero connection
ConnectionType.custom // Establish a JDBC connection using a custom driver

Hive and PostgreSQL Connection

For Hive and PostgreSQL connections, provide the host, port, database name, username, and password:

const host = '<host>';
const port = '<port>';
const database = '<database_name>';
const username = '<username>';
const password = '<password>';

// Set optional parameters
const minpoolsize = '<min_pool_size>'
const maxpoolsize = '<max_pool_size>'

// For Hive
const jdbc = new JdbcDriver(ConnectionType.hive, { host, port, database, username, password });

// For Hive with connection url
const jdbcUrl = 'jdbc:hive2://<host>:<port>/<database>'
const jdbc = new JdbcDriver(ConnectionType.hive, { jdbcUrl, username, password });

// For PostgreSql
const jdbc = new JdbcDriver(ConnectionType.postgreSql, { host, port, database, username, password });

// For PostgreSql with connection url
const jdbcUrl = 'jdbc:postgresql://<host>:<port>/<database>'
const jdbc = new JdbcDriver(ConnectionType.postgreSql, { jdbcUrl, username, password });

// For tibero connection
const jdbc = new JdbcDriver(ConnectionType.tibero, { host, port, database, username, password });

SQLite Connection

For SQLite connections, provide the path to the SQLite database file:

const path = '<db_path>';

// Set optional parameters
const minpoolsize = '<min_pool_size>'
const maxpoolsize = '<max_pool_size>'

const jdbc = new JdbcDriver(ConnectionType.sqlite, { path });

JDBC Connection using custom driver

 const jdbc = new JdbcDriver(ConnectionType.custom, {
        jars: 'sqlite-jdbc-3.7.2.jar', // local path of your jar file
        driverClass: 'org.sqlite.JDBC', // Driver class of your jar file
        jdbcUrl: 'jdbc:sqlite:/Users/jaynathray/Downloads/demo' // use jdbc url for connection
})
 const jdbc = new JdbcDriver(ConnectionType.custom, {
        jars: 'sqlite-jdbc-3.7.2.jar', // local path of your jar file
        driverClass: 'org.sqlite.JDBC', // Driver class of your jar file
        path: '/Users/jaynathray/Downloads/demo' // use path for connection
})

Basic Operations

Here are some basic operations you can perform using the node-jdbc-driver:

Check Driver Version

You can check the driver version using the following method:

const version = jdbc.get_version();

Count Example

To count the number of rows in a table:

const total = await jdbc.count('<table_name>');

Find Example

To find a single row based on a WHERE clause:

const row = await jdbc.find('<table_name>', '<where_clause>');

Find All Example

To retrieve all rows from a table:

const rows = await jdbc.findAll('<table_name>');

SQL Query Example

To execute a custom SQL query:

const results = await jdbc.sql('<sql_query>');

DDL Example

To execute Data Definition Language (DDL) queries:

const results = await jdbc.ddl('<sql_query>');

List Table Columns

To retrieve information about table columns:

const columns = await jdbc.get_columns('<table_name>');

Describe Table Properties

To get properties of a table:

const tblProperties = await jdbc.get_table_properties('<table_name>');

License

This project is licensed under the MIT License - see the LICENSE file for details.