Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DTP » Executing SQL statement
Executing SQL statement [message #51367] Tue, 11 November 2008 17:08 Go to next message
Eclipse User
Originally posted by: andi.hotz.adsl.li

Up until now when I was interested in the contents of a table I accessed
the contents through an SQL statement using the java.sql.* package.
With DTP this is something like the flowing:

IConnectionProfile profile;
....
String sql = "select * from some_table";
Connection conn = (Connection)
profile.createConnection("java.sql.Connection").getRawConnection();
try {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
if (rs.next()){
// something found found so do something
} else {
// nothing found so do something else
}
} catch (SQLException e){
e.printStackTrace();
}

I noticed there are classes/interfaces like
org.eclipse.datatools.modelbase.sql.query.impl.QuerySelectSt atementImpl.
How can I make use of this to access the data in my database table while
ignoring the underling connection infrastructure (JDBC connection will
only work if the data source driver is a JDBC driver).
So here is the question: How do I access my data in an abstract way?

I hope someone has some helpful thoughts.

Cheers

Andy
Re: Executing SQL statement [message #51395 is a reply to message #51367] Wed, 12 November 2008 02:25 Go to previous messageGo to next message
Brian Payton is currently offline Brian Payton
Messages: 152
Registered: July 2009
Senior Member
The Query model classes such as QuerySelectStatement are not really
intended to be used to access the data in your tables. They are used to
analyze and build SQL statements, particularly DML (Select, Insert,
Update, Delete).

If you want to work with your table data at a level of abstraction above
JDBC, you might want to look at the ODA (Open Data Access) component of
DTP. Other possibilities are non-Eclipse frameworks such as Spring and
Hibernate.

Andi Hotz wrote:
> Up until now when I was interested in the contents of a table I accessed
> the contents through an SQL statement using the java.sql.* package.
> With DTP this is something like the flowing:
>
> IConnectionProfile profile;
> ...
> String sql = "select * from some_table";
> Connection conn = (Connection)
> profile.createConnection("java.sql.Connection").getRawConnection();
> try {
> Statement stmt = conn.createStatement();
> ResultSet rs = stmt.executeQuery(sql);
> if (rs.next()){
> // something found found so do something
> } else {
> // nothing found so do something else
> }
> } catch (SQLException e){
> e.printStackTrace();
> }
>
> I noticed there are classes/interfaces like
> org.eclipse.datatools.modelbase.sql.query.impl.QuerySelectSt atementImpl.
> How can I make use of this to access the data in my database table while
> ignoring the underling connection infrastructure (JDBC connection will
> only work if the data source driver is a JDBC driver).
> So here is the question: How do I access my data in an abstract way?
>
> I hope someone has some helpful thoughts.
>
> Cheers
>
> Andy
Re: Executing SQL statement [message #51423 is a reply to message #51395] Wed, 12 November 2008 15:24 Go to previous messageGo to next message
Shaun Smith is currently offline Shaun Smith
Messages: 197
Registered: July 2009
Senior Member
Brian Payton wrote:

> If you want to work with your table data at a level of abstraction above
> JDBC, you might want to look at the ODA (Open Data Access) component of
> DTP. Other possibilities are non-Eclipse frameworks such as Spring and
> Hibernate.

You certainly don't need to use Non-Eclipse frameworks for this. :-)

EclipseLink provides the Java Persistence API 2.0 reference implementation
and is available as either a set of OSGi bundles or as a plain Java jar.
If you're looking for object-relational mapping then check out EclipseLink
and the Eclipse Dali Java Persistence Tools project for intelligent design
time tooling.

--Shaun

http://www.eclipse.org/eclipselink
http://www.eclipse.org/dali

NB: Dali uses DTP for database and schema information!
Re: Executing SQL statement [message #51479 is a reply to message #51423] Wed, 12 November 2008 19:52 Go to previous message
Eclipse User
Originally posted by: andi.hotz.adsl.li

Thanks for your tips

I had a look at ODA and found a lot of interfaces and could construct an
example to get my data starting from an IDriver. I could not figure out
how to retrieve any instance of this interface. Is there a way?

I also had a quick look at Eclipselink and Dali. Eclipselink is
certainly interesting but with the vocal point on databases perhaps not
the best choice. Dali seems a bit heavy weight with the installation of
an application server for JPA. I figure the interesting classes are in
the package org.eclipse.jpt.db. What I'm not sure about is if I can use
these classes without JPA since persistence is not my main focus.

So thanks again for your input

Andy

Shaun Smith wrote:
> Brian Payton wrote:
>
>> If you want to work with your table data at a level of abstraction
>> above JDBC, you might want to look at the ODA (Open Data Access)
>> component of DTP. Other possibilities are non-Eclipse frameworks such
>> as Spring and Hibernate.
>
> You certainly don't need to use Non-Eclipse frameworks for this. :-)
>
> EclipseLink provides the Java Persistence API 2.0 reference
> implementation and is available as either a set of OSGi bundles or as a
> plain Java jar. If you're looking for object-relational mapping then
> check out EclipseLink and the Eclipse Dali Java Persistence Tools
> project for intelligent design time tooling.
>
> --Shaun
>
> http://www.eclipse.org/eclipselink
> http://www.eclipse.org/dali
>
> NB: Dali uses DTP for database and schema information!
>
Re: Executing SQL statement [message #593821 is a reply to message #51367] Wed, 12 November 2008 02:25 Go to previous message
Brian Payton is currently offline Brian Payton
Messages: 152
Registered: July 2009
Senior Member
The Query model classes such as QuerySelectStatement are not really
intended to be used to access the data in your tables. They are used to
analyze and build SQL statements, particularly DML (Select, Insert,
Update, Delete).

If you want to work with your table data at a level of abstraction above
JDBC, you might want to look at the ODA (Open Data Access) component of
DTP. Other possibilities are non-Eclipse frameworks such as Spring and
Hibernate.

Andi Hotz wrote:
> Up until now when I was interested in the contents of a table I accessed
> the contents through an SQL statement using the java.sql.* package.
> With DTP this is something like the flowing:
>
> IConnectionProfile profile;
> ...
> String sql = "select * from some_table";
> Connection conn = (Connection)
> profile.createConnection("java.sql.Connection").getRawConnection();
> try {
> Statement stmt = conn.createStatement();
> ResultSet rs = stmt.executeQuery(sql);
> if (rs.next()){
> // something found found so do something
> } else {
> // nothing found so do something else
> }
> } catch (SQLException e){
> e.printStackTrace();
> }
>
> I noticed there are classes/interfaces like
> org.eclipse.datatools.modelbase.sql.query.impl.QuerySelectSt atementImpl.
> How can I make use of this to access the data in my database table while
> ignoring the underling connection infrastructure (JDBC connection will
> only work if the data source driver is a JDBC driver).
> So here is the question: How do I access my data in an abstract way?
>
> I hope someone has some helpful thoughts.
>
> Cheers
>
> Andy
Re: Executing SQL statement [message #593829 is a reply to message #51395] Wed, 12 November 2008 15:24 Go to previous message
Shaun Smith is currently offline Shaun Smith
Messages: 197
Registered: July 2009
Senior Member
Brian Payton wrote:

> If you want to work with your table data at a level of abstraction above
> JDBC, you might want to look at the ODA (Open Data Access) component of
> DTP. Other possibilities are non-Eclipse frameworks such as Spring and
> Hibernate.

You certainly don't need to use Non-Eclipse frameworks for this. :-)

EclipseLink provides the Java Persistence API 2.0 reference implementation
and is available as either a set of OSGi bundles or as a plain Java jar.
If you're looking for object-relational mapping then check out EclipseLink
and the Eclipse Dali Java Persistence Tools project for intelligent design
time tooling.

--Shaun

http://www.eclipse.org/eclipselink
http://www.eclipse.org/dali

NB: Dali uses DTP for database and schema information!
Re: Executing SQL statement [message #593872 is a reply to message #51423] Wed, 12 November 2008 19:52 Go to previous message
Eclipse User
Originally posted by: andi.hotz.adsl.li

Thanks for your tips

I had a look at ODA and found a lot of interfaces and could construct an
example to get my data starting from an IDriver. I could not figure out
how to retrieve any instance of this interface. Is there a way?

I also had a quick look at Eclipselink and Dali. Eclipselink is
certainly interesting but with the vocal point on databases perhaps not
the best choice. Dali seems a bit heavy weight with the installation of
an application server for JPA. I figure the interesting classes are in
the package org.eclipse.jpt.db. What I'm not sure about is if I can use
these classes without JPA since persistence is not my main focus.

So thanks again for your input

Andy

Shaun Smith wrote:
> Brian Payton wrote:
>
>> If you want to work with your table data at a level of abstraction
>> above JDBC, you might want to look at the ODA (Open Data Access)
>> component of DTP. Other possibilities are non-Eclipse frameworks such
>> as Spring and Hibernate.
>
> You certainly don't need to use Non-Eclipse frameworks for this. :-)
>
> EclipseLink provides the Java Persistence API 2.0 reference
> implementation and is available as either a set of OSGi bundles or as a
> plain Java jar. If you're looking for object-relational mapping then
> check out EclipseLink and the Eclipse Dali Java Persistence Tools
> project for intelligent design time tooling.
>
> --Shaun
>
> http://www.eclipse.org/eclipselink
> http://www.eclipse.org/dali
>
> NB: Dali uses DTP for database and schema information!
>
Previous Topic:Multiple Statement Delimiter
Next Topic:Multiple Statement Delimiter
Goto Forum:
  


Current Time: Tue Oct 21 02:31:11 GMT 2014

Powered by FUDForum. Page generated in 0.01853 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software