asharif/mv-session-mgr
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Copyright (C) 2012 by Arash Sharif Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- INTRODUCTION: This project provides a wrapper on the TigerLogic provided MVSP Java connectors to allow for connection pooling. The wrapper comes with a Connection class that has methods custom built for the unofficial '|' seperated Items or records and the 'Attribute Symbol' seperated attributes or columns -------------------------------------------------------------------------------- DEPENDENCIES: The mvapi.jar is the underlying MVSP provided by TigerLogic. It is a dependency for this project and can be dowloaded from their ftp site ftp://ftp.tigerlogic.com/pub/MVSP/Java/ (it's packaged in the MVSPJavaAPI.zip) -------------------------------------------------------------------------------- HOW TO BUILD: 1. Need maven 2. Uses the assembly plugin to maven to create single jar http://maven.apache.org/plugins/maven-assembly-plugin/ 3. To build: mvn package HOW TO USE: 1. Add from step2 to class path 2. Call the session manager like described in sample class below: package com.foo; import java.sql.ResultSet; import java.sql.SQLException; import javax.management.InstanceAlreadyExistsException; import javax.management.MBeanRegistrationException; import javax.management.MalformedObjectNameException; import javax.management.NotCompliantMBeanException; import org.orphanware.mv.sessionmgr.MVConnection; import org.orphanware.mv.sessionmgr.MVSessionMgr; /** * * @author arash */ public class MVJDBCProxy { private MVConnection conn; private MVSessionMgr mvSessionMgr; public MVJDBCProxy() throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, SQLException{ mvSessionMgr = MVSessionMgr.getInstance(); mvSessionMgr.setUser("${mv.login}")); //default is MVSP mvSessionMgr.setPassword("${mv.loginpass}"); //default is *blank* mvSessionMgr.setAccount("${mv.account}"); //whatever account u want to login to mvSessionMgr.setAccountPassword("${mv.accountpass}"); //the account password mvSessionMgr.setUrl("${mv.addr}")); //jdbc:mv:mvbase:*.*.*.*:9010 mvSessionMgr.setPoolsize(5); //any num as long as u have licenses conn = (MVConnection) mvSessionMgr.getConnection(); } public ResultSet callMVSub(String subName, String params) throws SQLException, Exception { ResultSet rs = null; try { rs = conn.callMVSub(subName, params); } catch( Exception e) { } finally { conn.close(); } return rs; } public ResultSet callMVSubLongWait(String subName, String params, int longWaitTime) throws SQLException, Exception { ResultSet rs = null; try { rs = conn.callMVSub(subName, params, longWaitTime); } catch( Exception e) { } finally { conn.close(); } return rs; } } ------------------------------------------- 3. access data like so: MVJDBCProxy mvproxy = new MVJDBCProxy(); MVResultSet rs = (MVResultSet) mvproxy.callMVSub("HELLO.WORLD", "param1|param2"); //HELLO.WORLD is just example. it would have to exist in account and be cataloged if (rs.getNumRows() == 0) { renderText(""); return; } String[][] rows = new String[rs.getNumRows()][rs.getNumAttributes()]; int i = 0; do { logger.debug("row " + i + " has " + rs.getNumAttributes() + " columns: " + rs.getRow(i)); String[] attrbs = new String[rs.getNumAttributes()]; for (int j = 0; j < rows[i].length; j++) { attrbs[j] = rs.getAttrString(j); } rows[i] = attrbs; i++; } while (rs.next());
About
MVSP connection pooling for mvBase and D3
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published