UPDATE: This repo is obsolete it's replaced by https://github.com/asharif/mv-session-mgr
Created a new project to attempt to be connecting to mvBase in a uniform JDBC compliant way. It also handles multiple threads as the original MVSP connectors don't somehow...(yikes!)
Check it out:
https://github.com/asharif/mv.jdbc
Showing posts with label mvbase. Show all posts
Showing posts with label mvbase. Show all posts
Tuesday, June 28, 2011
Tuesday, June 14, 2011
Connecting to mvBase 3.0 with Java
A couple posts back I went through the basics of PICK (mvBase). I finally got a chance to connect to it using the mvBase 3.0 MVSP with Java. First off we need the mvapi.jar which acts as our jdbc like interface (UPDATE: MVSP alone is actually hard to use in a web app as it does not handle any connection pooling and basically only allows one active connection at a time. It also doesn't work in a standard JDBC compliant manner which is why I started a project https://github.com/asharif/mv-session-mgr). I downloaded it off the tigerlogic ftp site ftp://ftp.tigerlogic.com/pub/MVSP/Java/
There are some samples in that zip file as well. Then it was just a matter of writing a bit of code:
There are some samples in that zip file as well. Then it was just a matter of writing a bit of code:
package comuniversalmetalsmvbase; import com.tigr.mvapi.MVConnection; import com.tigr.mvapi.MVConstants; import com.tigr.mvapi.MVStatement; import com.tigr.mvapi.ResultSet.MVResultSet; import com.tigr.mvapi.exceptions.MVException; import java.util.Properties; /** * * @author arash */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { Properties props = new Properties(); props.setProperty("username", "MVSP"); props.setProperty("password", ""); String url = "jdbc:mv:mvbase:192.168.1.5:9010"; String account = "SYSPROG"; String AM = MVConstants.AM; String query; MVConnection connection = null; try { connection = new MVConnection(url, props); /** * Execute a query and display the results: */ MVStatement mvStatement = connection.createStatement(); connection.logTo(account, ""); // query = "LIST CUSTOMERS (I"; //boolean result = mvStatement.execute(query); //MVResultSet results = mvStatement.getResultSet(); MVResultSet results = mvStatement.executeQuery("PEOPLE", "", "", "FIRST-NAME"); while (results.next()) { String row = results.getCurrentRow(); System.out.println(row); } } catch (MVException e) { System.out.println(e.toString()); } finally { if (connection != null) { try { connection.close(); } catch (MVException e) { e.printStackTrace(); } } } } }
Thursday, March 10, 2011
Learning PICK....
So for a new project I am starting to learn a little about PICK systems, specifically MVBase. Different way of thinking from SQL that's for sure. Anyway just some notes for myself as well as those who are looking to start...
everything is a file. you create a db with:
in above it's either ED or DE. Then enter the command
This will put you in an inline insert mode. Have to refer to the MVBase docs for specifics but the following:
The main thing here is 002 which is the order in which this fields shows up and 003 which is the header. 007 is the formatting of the text, 009 is justification and 010 is the width allocated in the command prompt for the column.
After this is done we need to create a data file for the dictionary like so:
Lasty you query the file like so
Next up....connecting and retriving this from Java! =)
everything is a file. you create a db with:
CREATE-FILE [DB_NAME] 3 43In the above the 3 and 43 are modulos??? and somehow represent the size of the file as well as the file dictionaly. The command above basically creates a file as well as a file dictionary or a specification on the schema if you will. Now to create the schmea:
[ED|DE] DICT PEOPLE P-ID
in above it's either ED or DE. Then enter the command
I
This will put you in an inline insert mode. Have to refer to the MVBase docs for specifics but the following:
>001 A 002 1 003 Customer ID 004 005 006 007 ML(#-####-####) 008 009 L 010 12
The main thing here is 002 which is the order in which this fields shows up and 003 which is the header. 007 is the formatting of the text, 009 is justification and 010 is the width allocated in the command prompt for the column.
After this is done we need to create a data file for the dictionary like so:
>ED DATA PEOPLE [id][id] can be anything it's just the name that you give the file. The important thing about this datafile is that it has to match the dictionary file. If in the DICT file you state on 002 that this field is item 1 then this the value in the data file NEEDS to be on the first line like so
>001 Arash
Lasty you query the file like so
>LIST PEOPLE FIRST-NAMEwhich should result in
>PEOPLE......First Name... ASHARI Arash
Next up....connecting and retriving this from Java! =)
Subscribe to:
Posts (Atom)