Page 2 of 2 FirstFirst 12
Results 21 to 30 of 30
Like Tree2Likes

Thread: Import image to embedded database and display into application?

  1. #21
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,090
    Rep Power
    20

    Default Re: Import image to embedded database and display into application?

    The URL 'jdbc:derby:bobo;create=true;test' is not properly formed.

    This has nothing to do with Netbeans...I've done a number of small Derby apps using it (and Eclipse).
    That URL is, as it says in the error, not correct.

    WHat is that "test" part for?
    Your database is called bobo...

    jdbc:derby:bobo;create=true

    That should be all you need.

  2. #22
    ogre is offline Member
    Join Date
    Jun 2011
    Posts
    17
    Rep Power
    0

    Default Re: Import image to embedded database and display into application?

    Quote Originally Posted by Tolls View Post
    The URL 'jdbc:derby:bobo;create=true;test' is not properly formed.

    This has nothing to do with Netbeans...I've done a number of small Derby apps using it (and Eclipse).
    That URL is, as it says in the error, not correct.

    WHat is that "test" part for?
    Your database is called bobo...

    jdbc:derby:bobo;create=true

    That should be all you need.
    Test was name of table, anyway when i change it i got java.sql.SQLException: The URL 'jdbc:derby:bobo;create=true;bobo' is not properly formed.

    That is a problem, i think that is not gona work to make fuctional Jfilechoser to upload image to blob field.

  3. #23
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,090
    Rep Power
    20

    Default Re: Import image to embedded database and display into application?

    You didn't read what I wrote.
    You don't put anything after the "create=true".
    Java Code:
    jdbc:derby:bobo;create=true
    You seem to be munging together something for a different database to Derby and are confusing yourself.

  4. #24
    ogre is offline Member
    Join Date
    Jun 2011
    Posts
    17
    Rep Power
    0

    Default Re: Import image to embedded database and display into application?

    Is the same error, i have try whit ; and whitout it. Same mistake.


    Java Code:
    java.sql.SQLException: JDBC attribute 'create' has an invalid value 'truebobo', valid values are '{true|false}'.
    Forgot to add that same insertImage.java dont end on fail importing image into database, ceap runing, must turn it off by my self.

    I was thinking that is a problem whit a netbeans code, first i make a mistake. To insert image into database i need to select a row at database. Like delete button

    Java Code:
    @Action(enabledProperty = "recordSelected")
        public void deleteRecord() {
            int[] selected = masterTable.getSelectedRows();
            List<img1.Test> toRemove = new ArrayList<img1.Test>(selected.length);
            for (int idx=0; idx<selected.length; idx++) {
                img1.Test t = list.get(masterTable.convertRowIndexToModel(selected[idx]));
                toRemove.add(t);
                entityManager.remove(t);
            }
            list.removeAll(toRemove);
            setSaveNeeded(true);
        }
    Whit that similar code i need to implement a Jfilechooser and then insert a image. I have make a java file who on run display image from HDD, that was easy one. So that will be last resort for Image solution.

  5. #25
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,090
    Rep Power
    20

    Default Re: Import image to embedded database and display into application?

    Gah!
    You are clearly not doing as I suggested!
    You would not get that error if the only thing you are putting into the URL part of getConnection() is the String I posted.
    You keep appending your dbName String to your URL!
    Stop doing that!

    Java Code:
    String url = "jdbc:derby:bobo;create=true";
    String userName = "app";
    String password = "app";
    Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
    Connection con = DriverManager.getConnection(url, userName, password);
    That is all you need!
    ogre likes this.

  6. #26
    ogre is offline Member
    Join Date
    Jun 2011
    Posts
    17
    Rep Power
    0

    Default Re: Import image to embedded database and display into application?

    Oh, i am so stupid!

    Java Code:
    java.sql.SQLException: An attempt was made to put a data value of type 'java.lang.String' into a data value of type 'BLOB'.
    SO Working, like my mother used to say "FOK YEAH!" - this is a joke but what a heck :)

    Btw Tolls thanks on your time and suggestions.
    Last edited by ogre; 01-06-2012 at 02:01 PM.

  7. #27
    ranss41 is offline Member
    Join Date
    Dec 2011
    Posts
    5
    Rep Power
    0

    Default Re: Import image to embedded database and display into application?

    I have different question... i'm making 2D grid. so from this forum i got the code for that. but nw i want to put Bg image to that grid. can anyone help me :)

    this is the code:

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;

    public class SquareGrid extends JPanel {
    SquareRx[][] squares;
    final int PAD = 20;
    final int ROWS = 10;
    final int COLS = 10;
    //private Image goodImg = Toolkit.getDefaultToolkit().getImage("images/bg1.jpg");

    public SquareGrid() {
    addMouseListener(ml);
    }

    protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASIN G,
    RenderingHints.VALUE_ANTIALIAS_ON);
    if(squares == null) {
    initSquares();
    }
    // Draw squares.

    g2.setPaint(Color.black);
    for(int i = 0; i < ROWS; i++) {
    for(int j = 0; j < COLS; j++) {
    squares[i][j].draw(g2);
    }
    }
    }
    private void initSquares() {
    squares = new SquareRx[ROWS][COLS];
    int w = getWidth();
    int h = getHeight();
    double xInc = (double)(w - 2*PAD)/COLS;
    double yInc = (double)(h - 2*PAD)/ROWS;
    for(int i = 0; i < ROWS; i++) {
    double y = PAD + i*yInc;
    for(int j = 0; j < COLS; j++) {
    double x = PAD + j*xInc;
    Rectangle2D.Double r =
    new Rectangle2D.Double(x, y, xInc, yInc);
    squares[i][j] = new SquareRx(i, j, r);
    }
    }
    }
    private MouseListener ml = new MouseAdapter() {
    public void mousePressed(MouseEvent e) {
    Point p = e.getPoint();
    if(!isInGrid(p)) return;
    double xInc = (double)(getWidth() - 2*PAD)/COLS;
    double yInc = (double)(getHeight() - 2*PAD)/ROWS;
    int row = (int)((p.y-PAD)/yInc);
    int col = (int)((p.x-PAD)/xInc);
    System.out.println(squares[row][col]);
    boolean isSelected = squares[row][col].isSelected();
    squares[row][col].setSelected(!isSelected);
    repaint();
    }
    };
    private boolean isInGrid(Point p) {
    Rectangle r = getBounds();
    r.grow(-PAD, -PAD);
    return r.contains(p); }
    public static void main(String[] args) {
    SquareGrid test = new SquareGrid();
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(test);
    f.setSize(400,400);
    f.setLocation(100,100);
    f.setVisible(true);
    test.addComponentListener(test.cl);
    }
    private ComponentListener cl = new ComponentAdapter() {
    public void componentResized(ComponentEvent e) {
    squares = null;
    repaint();
    }
    };
    }
    class SquareRx {
    private final int row;
    private final int col;
    Rectangle2D.Double rect;
    Color bgcolor = new Color(1,2,3);
    Color bgColor = Color.green;
    Color selColor = Color.green;
    private boolean selected = true;
    public SquareRx(int r, int c, Rectangle2D.Double rect) {
    row = r;
    col = c;
    this.rect = rect;
    }
    public void draw(Graphics2D g2) {
    g2.setPaint(selected ? selColor : bgColor);
    g2.fill(rect);
    g2.setPaint(bgcolor);
    g2.draw(rect);
    }
    public void setSelected(boolean selected) {
    this.selected = selected;
    }
    public boolean isSelected() { return selected; }
    public String toString() {
    return "SQUARE[row:" + row + ", col:" + col +
    ", selected:" + selected + "]";
    }
    }

  8. #28
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,090
    Rep Power
    20

    Default Re: Import image to embedded database and display into application?

    Don't hijack someone else's thread...start your own.
    quad64bit likes this.

  9. #29
    ogre is offline Member
    Join Date
    Jun 2011
    Posts
    17
    Rep Power
    0

    Default Re: Import image to embedded database and display into application?

    Okey I got problem whit implementig this insertImage file into program, nice. Okey tommorow then.
    I got Error from generated code, i will dilete project and make tommorow new one.
    Last edited by ogre; 01-06-2012 at 07:04 PM.

  10. #30
    ogre is offline Member
    Join Date
    Jun 2011
    Posts
    17
    Rep Power
    0

    Default Re: Import image to embedded database and display into application?

    Okey i make new project, and same as old one, and set new button, i give him action and call a insertimage file but that dosnt work.


    Java Code:
     @Action
        private void newImage() {
            insertImage insertImage = new insertImage();
          }
    Got errors
    Exception in thread "AWT-EventQueue-0" java.lang.Error: java.lang.IllegalAccessException: Class org.jdesktop.application.ApplicationAction can not access a member of class img2.Img2View with modifiers "private"
    Now i am officialy feel like retarded kid. So what i need to do to run that file?

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Embedded Database with Multi-Platform support
    By StormyWaters in forum JDBC
    Replies: 12
    Last Post: 12-12-2011, 06:20 PM
  2. Replies: 1
    Last Post: 07-28-2011, 08:48 AM
  3. Embedded Database ?
    By Prajin in forum JDBC
    Replies: 8
    Last Post: 09-27-2010, 06:44 AM
  4. Replies: 1
    Last Post: 10-06-2008, 02:55 AM
  5. How to display a database-image in a page?
    By simon in forum New To Java
    Replies: 1
    Last Post: 07-23-2007, 11:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •