• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Save URL's in a table in a Derby database.

 
Greenhorn
Posts: 20
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Guys, I want to save URL's in a table in a Derby database.

I'm using embedded derby in this code.
This is it:



Main Sql statement from above code:
"create table SITES(page varchar(2083), inner varchar(2083), external varchar(2083))"

But I got an error:


Maybe there is some other way?

My goal is to create page_URL and put INNER and EXTERNAL URL's associated with page_URL from my Java program to this table.
For example:
Column1: Main page URL.
Column2: inner URL's ,
Column3: external_URL's.
and so on for another URL.

I'm new to this.
 
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would help if you posted both the error message and the code which caused the error message. As it stands now, we have to click on a link to an external site to find out that neither of those two are available. Post them both here, that would be easier both for you and for anybody interested in helping.
 
Kirill Varivoda
Greenhorn
Posts: 20
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:It would help if you posted both the error message and the code which caused the error message. As it stands now, we have to click on a link to an external site to find out that neither of those two are available. Post them both here, that would be easier both for you and for anybody interested in helping.



Ok, I've changed my post.
 
Marshal
Posts: 3720
533
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your database table is probably not getting created because inner is a reserved word - if you want to use it as a column name, you will need to enclose it in back-ticks.

stmt.execute("create table " + tableName + "(page varchar(2083), `inner` varchar(2083), external varchar(2083))");
 
Kirill Varivoda
Greenhorn
Posts: 20
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:Your database table is probably not getting created because inner is a reserved word - if you want to use it as a column name, you will need to enclose it in back-ticks.

stmt.execute("create table " + tableName + "(page varchar(2083), `inner` varchar(2083), external varchar(2083))");



Thanks for this, I changed a line



but now I got a new error.

 
Ron McLeod
Marshal
Posts: 3720
533
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at this line and pay attention to the how you are quoting the string values:

stmt.execute("insert into " + tableName + " values (" + page + ",'" + inner + "','" + external + "')");
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:Take a look at this line and pay attention to the how you are quoting the string values:

stmt.execute("insert into " + tableName + " values (" + page + ",'" + inner + "','" + external + "')");



And then use a PreparedStatement...
 
Kirill Varivoda
Greenhorn
Posts: 20
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:Take a look at this line and pay attention to the how you are quoting the string values:

stmt.execute("insert into " + tableName + " values (" + page + ",'" + inner + "','" + external + "')");



Thank you! I've found a mistake:
stmt.execute("insert into " + tableName + " values ('" + page + "','" + inner + "','" + external + "')");
 
Kirill Varivoda
Greenhorn
Posts: 20
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:

Ron McLeod wrote:Take a look at this line and pay attention to the how you are quoting the string values:

stmt.execute("insert into " + tableName + " values (" + page + ",'" + inner + "','" + external + "')");



And then use a PreparedStatement...



Ok! I study what you've send. Thank you.
 
Marshal
Posts: 74376
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this would fit better in our databases forum: moving.

Why have you got so many static methods?
 
Kirill Varivoda
Greenhorn
Posts: 20
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:I think this would fit better in our databases forum: moving.

Why have you got so many static methods?



Ok. I don't know actually. Big part of this code was found on internet, I just use it.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic