[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Octave + PostgreSQL + JDBC
From: |
ggv |
Subject: |
Octave + PostgreSQL + JDBC |
Date: |
Thu, 11 Aug 2011 21:48:06 -0700 (PDT) |
Greetings to all, this is my first post to this list
I am experimenting with Octave for an application that will need access to a
PostgreSQL database. I am trying out the JDBC following an example
written for Matlab. I am running Octave 3.2.4 under Ubuntu 11.04 and
installed package java-1.2.8 from Octave Forge.
I actually got the example below to work, but would like to hear from more
experienced users if this is a reasonable approach. Thanking you in
advance, here is my code:
% ----- PostgreSQL with JDBC ----
% Add jar file to classpath
javaaddpath('postgresql-jdbc3-8.4.jar');
% Username and password you chose when installing postgres
props=javaObject('java.util.Properties');
props.setProperty("user", 'myself');
props.setProperty("password", 'nottellingyou');
% Create database connection
driver=javaObject('org.postgresql.Driver');
url='jdbc:postgresql://localhost:5432/testdb';
conn=driver.connect(url, props);
% Test query
sql='select max("Session_Date") from "TestTable"'
ps=conn.prepareStatement(sql);
rs=ps.executeQuery();
% Retrieve results into array
count=0;
result=struct;
while rs.next()
count=count+1;
result(count)=char(rs.getString(1));
end
--
View this message in context:
http://octave.1599824.n4.nabble.com/Octave-PostgreSQL-JDBC-tp3737921p3737921.html
Sent from the Octave - General mailing list archive at Nabble.com.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Octave + PostgreSQL + JDBC,
ggv <=