Re: DBRepository problems
Florin PATRASCU <[email protected]> Mon, 16 Feb 2004 19:41:56 -0400
| Newsgroups | gmane.comp.java.jpublish.devel |
|---|---|
| Message-ID | <6.0.1.1.2.20040216192107.02b145b0@POP> |
Juan - try first to use hsqldb as a standalone db:
.... the URL for Windows
<url>jdbc:hsqldb:E:\jboss\server\default\data\hypersonic\jpublish</url>
... or:
<url>jdbc:hsqldb:/opt/jboss/server/default/data/hypersonic/jpublish</url>
if you have a Linux box. Of course you need to tune your file path=20
accordingly ;)
1. I suspect you cannot connect to the datasource TC is maintaining. Check=
if:
jdbc:hsqldb:hsql://localhost:9001 is available for socket connections. I=20
know JBoss, due to a security issue, disabled the above usage of hsqldb.
If, in standalone works, then we have to look further for Tomcat settings.
2. However, I believe that your db structure also can create you a problem.=
=20
I was trying to use your structure and I got Error:null .. but because of=
this:
[SiteContext] Error getting content: Wrong data type: type: TIMESTAMP=20
(93) expected: BIGINT value: 2004-01-13 01:22:00.0
[STDERR] java.sql.SQLException: Wrong data type: type: TIMESTAMP (93)=20
expected: BIGINT value: 2004-01-13 01:22:00.0
[STDERR] at org.hsqldb.Trace.getError(Unknown Source)
:'(
Try to use my table structure:
create table contenido(
path varchar(255) primary key,
body longvarchar(1000) not null,
LAST_MODIFIED BIGINT
)
Please run a test with hsqldb in standalone mode and let us know. I am sure=
=20
we'll find an answer.
Also, are you sure you need to serve pages from the db, or this is a test=20
you want to try?
Sincerely,
-Florin
At 16/02/2004 15:13, Juan Carl wrote:
>Hi Florin,
>
>Thanks for your help. I've tested the same example but
>it doesn't work in my site :( The same problem
>continues...
>The exception thrown by Tomcat was:
>
>java.lang.NullPointerException
> at
>org.jpublish.repository.db.DBRepository.get(DBRepository.java:147)
> at
>org.jpublish.repository.db.DBRepository.get(DBRepository.java:169)
>...
>
>I've also inspected the code from DBRepository.java at
>line 147 (from public String get(String path))
>
>Connection c =3D null;
> try{
> log.debug("Connecting to database.");
> c =3D DriverManager.getConnection(url,
>username, password);
>
> PreparedStatement s =3D
>c.prepareStatement(contentQuery);
> s.setString(1, path);
>
> log.debug("Executing query.");
> ResultSet r =3D s.executeQuery();
> if(r.next()){
> return r.getString(1);
> } else {
> throw new Exception("Path not found: "
>+ path);
> }
> } finally {
> c.close(); //Line 147
> }
>It seems the DriverManager can't establish a
>connection with the database. I've tested both server
>and standalone HSQLDB modes (v 1.7.1 and 1.7.2). I
>think the URL string is correct.
>
>The db schema:
>
>CREATE TABLE contenido (
> id_contenido INTEGER PRIMARY KEY,
> path VARCHAR(255) not null,
> body LONGVARCHAR(1000) not null,
> last_modified DATETIME not null
>);
>
>with only 1 tuple stored:
>
>INSERT INTO Contenido VALUES(1,'/index.html',
>'<p>Index page</p>', '2004-01-13 01:22:00')
>
>I really have no ideas... :(
>Thanks again for your help...
>
> Juan Pablo
>
>
> --- Florin PATRASCU <[email protected]> escribi=F3: > Hi
>Juan,
> >
> > Please be sure the path to your hsqldb is correct.
> > In my example below,
> > everything works smooth. Let us know if the example
> > below was helpful.
> > Cheers - Florin
> >
> > a. I am creating a sample HSQLD table and I am
> > populating it with some data:
> >
> > drop table CONTENIDO
> > create table contenido(
> > path varchar(255) primary key,
> > data longvarchar(1000) not null,
> > LAST_MODIFIED BIGINT
> > )
> > select * from CONTENIDO
> > INSERT INTO CONTENIDO(path,data,last_modified)
> > VALUES('/index.html',
> > 'SALUD!', 2004)
> >
> >
> > b. On my Windows environment, in jpublish.xml I
> > have:
> > <repository name=3D"db_repository"
> > classname=3D"org.jpublish.repository.db.DBRepository">
> > <driver>org.hsqldb.jdbcDriver</driver>
> >
> >
><url>jdbc:hsqldb:E:\jboss\server\default\data\hypersonic\jpublish</url>
> > <username>sa</username>
> > <password></password>
> > <content-query>select data from
> > contenido where path =3D
> > ?</content-query>
> > <last-modified-query>select
> > last_modified from contenido where
> > path =3D ?</last-modified-query>
> > <paths-query>select * from contenido
> > where path like
> > ?</paths-query>
> > </repository>
> >
> > c. starting up JBOSS (I know you have TOMCAT, but it
> > should work at your
> > side as well:)
> > and after calling: http://localhost/jpdb/index.html
> >
> > I see:
> > SALUD!
> >
> > ...
> >
> > QED :)
> > As I've said, let us now if you need more help!
> >
> > -Florin
> >
> >
> >
> > At 15/02/2004 20:26, you wrote:
> > >Hello..
> > >I'm trying to run the jpublish-example with the
> > >content stored in a HSQLDB database, but I receive
> > >this message (in the browser) when I try to read
> > the
> > >page: "Error: null".
> > >It seems there isn't a problem with the SQL
> > statement.
> > >I think it's a problem with the connection, because
> > I
> > >can't see any signal from the org.hsqldb.Server
> > when I
> > >do the $db_repository.get($page.Path) from the
> > >template. I've the hsqldb.jar in the /lib
> > directory.
> > >
> > >This is my db configuration in the jpublish.xml
> > >(similar to the jpublish-example)
> > >
> > ><repository name=3D"db_repository"
> >
> >classname=3D"org.jpublish.repository.db.DBRepository">
> > > <driver>org.hsqldb.jdbcDriver</driver>
> > >
> > <url>jdbc:hsqldb:hsql://localhost:9001</url>
> > > <username>sa</username>
> > > <password></password>
> > > <content-query>select body from
> > contenido where
> > >path =3D ?</content-query>
> > > <last-modified-query>select
> > last_modified from
> > >contenido where path =3D ?</last-modified-query>
> > > <paths-query>select * from contenido
> > where path
> > >like ?</paths-query>
> > > </repository>
> > >
> > >
> > >The table in my database is "contenido" and has the
> > >same attributes I've seen in the
> > jpublish-example...
> > >The server is running ok, because I've connected to
> > it
> > >from the hsqldb DatabaseManager...
> > >=BFWhat I'm doing wrong?
> > >
> > >Please apologize me if it's a basic question, but I
> > >need some help.
> > >
> > >Thanks a lot...
> > >
> > > Juan Pablo
> > >
> > >PD: I'm using JPublish 2.0, Tomcat 4.1.24 and
> > HSQLDB 1.7
> > >
>
>
>=3D=3D=3D=3D=3D
>Juan Pablo Carlino (LW4DYI)
>[email protected]
>Tandil - Argentina
>
>------------
>Los mejores usados y las m=E1s tentadoras
>ofertas de 0km est=E1n en Yahoo! Autos.
>Compr=E1 o vend=E9 tu auto en
>http://autos.yahoo.com.ar
>
>
>-------------------------------------------------------
>SF.Net is sponsored by: Speed Start Your Linux Apps Now.
>Build and deploy apps & Web services for Linux with
>a free DVD software kit from IBM. Click Now!
>http://ads.osdn.com/?ad_id=3D1356&alloc_id=3D3438&op=3Dclick
>_______________________________________________
>Jpublish-developer mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/jpublish-developer
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click