Re: Problem storing an image in a Blob field in Java DB.
Dinesh Bajaj wrote: preparedStatement.setBinaryStream(5, inputStream, file.length()); Message = Java exception: 'Input stream did not have exact amount of data as the requested length.: Can you show more of your actual code? It sounds like 'inputStream' is not returning the data which is in 'file'. Paste in a larger segment of your code, showing all the activity to 'inputStream' and 'file' since they were declared as variables. thanks, bryan
Re: Problem storing an image in a Blob field in Java DB.
Hi Bryan, Kristian and Arin, Many thanks for your replies. The first post to this thread was also my first post to this forum, and I understand it was therefore moderated. It appears that due to a technical fault, it was not forwarded to the list members. Coming back to the issue, I have now figured out the root cause of the problem. The problem was arising as I was invoking the method ImageIO.read(fis) on the FileInputStream instance, before sending the same stream instance to the SetBinaryStream method. I understand that reading the inputstream was causing the pointer to move to the end of the stream, and therefore no data was getting stored in the Derby database. I amended the code, and the problem is now fixed. What a great relieve as this problem was bugging me for the last 3-4 days, and I can't believe that I couldn't figure it out earlier. Anyways, many thanks for all your input. Regards, Dinesh --- On Fri, 12/2/10, Bryan Pendleton bpendle...@amberpoint.com wrote: From: Bryan Pendleton bpendle...@amberpoint.com Subject: Re: Problem storing an image in a Blob field in Java DB. To: Derby Discussion derby-user@db.apache.org Date: Friday, 12 February, 2010, 8:57 PM Dinesh Bajaj wrote: preparedStatement.setBinaryStream(5, inputStream, file.length()); Message = Java exception: 'Input stream did not have exact amount of data as the requested length.: Can you show more of your actual code? It sounds like 'inputStream' is not returning the data which is in 'file'. Paste in a larger segment of your code, showing all the activity to 'inputStream' and 'file' since they were declared as variables. thanks, bryan Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! http://downloads.yahoo.com/in/internetexplorer/
refresh JSP webpage when Derby DB is changed
The goal is to refresh a JSP web page on a web browser when the Derby DB on the server is changed. The rate of database change is 1-10 times per hour. The record size is about 1000 bytes. The user use the browser to modify the data and write back to the Derby DB. The web server is tomcat. I am thinking of comet programming - pushing data from the server to client when the Derby DB is changed. Is that a good idea? How to do that with javascript or java? Any sample code or tutorial? -- View this message in context: http://old.nabble.com/refresh-JSP-webpage-when-Derby-DB-is-changed-tp27565891p27565891.html Sent from the Apache Derby Users mailing list archive at Nabble.com.
Re: refresh JSP webpage when Derby DB is changed
This isn't really a Derby question, it's more of a web/Javascript question. There is no way to push data to a client. The request always originates on the client. That said, IF you are so inclined you can use Ajax type calls to poll a servlet on the server on a regular interval to check for updates. It would still be polling, though. Not event-based. I would look at prototype if you want to start leveraging Ajax. http://www.prototypejs.org/ It's a good place to start. I would be very careful about having JS continuously polling your server though. If you have lots of clients you will end up with lots of requests to handle. That code has to be very efficient. On Feb 12, 2010, at 11:17:22 AM, albertkao wrote: The goal is to refresh a JSP web page on a web browser when the Derby DB on the server is changed. The rate of database change is 1-10 times per hour. The record size is about 1000 bytes. The user use the browser to modify the data and write back to the Derby DB. The web server is tomcat. I am thinking of comet programming - pushing data from the server to client when the Derby DB is changed. Is that a good idea? How to do that with javascript or java? Any sample code or tutorial? -- View this message in context: http://old.nabble.com/refresh-JSP-webpage-when-Derby-DB-is-changed-tp27565891p27565891.html Sent from the Apache Derby Users mailing list archive at Nabble.com.
Re: refresh JSP webpage when Derby DB is changed
The goal is to refresh a JSP web page on a web browser when the Derby DB on the server is changed. I agree with Ronald Rudy's observation that the web browser itself will need to initiate the polling request. Meanwhile, on the server side, Derby supports triggers, which you can use to track the changes on the server side, which will help you make your polling efficient: http://db.apache.org/derby/docs/10.5/devguide/cdevspecial27163.html thanks, bryan
Re: refresh JSP webpage when Derby DB is changed
Ronald Rudy wrote: This isn't really a Derby question, it's more of a web/Javascript question. There is no way to push data to a client. The request always originates on the client. That said, IF you are so inclined you can use Ajax type calls to poll a servlet on the server on a regular interval to check for updates. It would still be polling, though. Not event-based. Hi, While the original request has to originate from the client, you don't have to have the client poll on regular intervals - you can use something like long poll or streaming to basically get an event-based system. Note that this requires some software on the server side, and as most things these techniques have their challenges. Besides from the link already mentioned, you can have a look at Atmosphere ( https://atmosphere.dev.java.net/ ) and maybe post a question there or on a similer mailing list / forum. Hope this helps, -- Kristian I would look at prototype if you want to start leveraging Ajax. http://www.prototypejs.org/ It's a good place to start. I would be very careful about having JS continuously polling your server though. If you have lots of clients you will end up with lots of requests to handle. That code has to be very efficient. On Feb 12, 2010, at 11:17:22 AM, albertkao wrote: The goal is to refresh a JSP web page on a web browser when the Derby DB on the server is changed. The rate of database change is 1-10 times per hour. The record size is about 1000 bytes. The user use the browser to modify the data and write back to the Derby DB. The web server is tomcat. I am thinking of comet programming - pushing data from the server to client when the Derby DB is changed. Is that a good idea? How to do that with javascript or java? Any sample code or tutorial? -- View this message in context: http://old.nabble.com/refresh-JSP-webpage-when-Derby-DB-is-changed-tp27565891p27565891.html Sent from the Apache Derby Users mailing list archive at Nabble.com.
Re: refresh JSP webpage when Derby DB is changed
There IS a way to push data to the client, and I am using it successfully right now. It's called WebSocket and its part of HTML5, but only a few servers and browsers support it at the moment. Jetty 7 is one such server, and apparently later versions of WebKit and Gecko support it on the browser side (im not sure since my WebSocket client is a Java application which I wrote myself). Otherwise you can use Bayeux/Cometd to do long polling which simulates server push (its horridly complex compared to WebSockets depending on what you want to do with it, but it is much more widely supported) Erin On Sat, Feb 13, 2010 at 8:49 AM, Kristian Waagan kristian.waa...@sun.com wrote: Ronald Rudy wrote: This isn't really a Derby question, it's more of a web/Javascript question. There is no way to push data to a client. The request always originates on the client. That said, IF you are so inclined you can use Ajax type calls to poll a servlet on the server on a regular interval to check for updates. It would still be polling, though. Not event-based. Hi, While the original request has to originate from the client, you don't have to have the client poll on regular intervals - you can use something like long poll or streaming to basically get an event-based system. Note that this requires some software on the server side, and as most things these techniques have their challenges. Besides from the link already mentioned, you can have a look at Atmosphere ( https://atmosphere.dev.java.net/ ) and maybe post a question there or on a similer mailing list / forum. Hope this helps, -- Kristian I would look at prototype if you want to start leveraging Ajax. http://www.prototypejs.org/ It's a good place to start. I would be very careful about having JS continuously polling your server though. If you have lots of clients you will end up with lots of requests to handle. That code has to be very efficient. On Feb 12, 2010, at 11:17:22 AM, albertkao wrote: The goal is to refresh a JSP web page on a web browser when the Derby DB on the server is changed. The rate of database change is 1-10 times per hour. The record size is about 1000 bytes. The user use the browser to modify the data and write back to the Derby DB. The web server is tomcat. I am thinking of comet programming - pushing data from the server to client when the Derby DB is changed. Is that a good idea? How to do that with javascript or java? Any sample code or tutorial? -- View this message in context: http://old.nabble.com/refresh-JSP-webpage-when-Derby-DB-is-changed-tp27565891p27565891.html Sent from the Apache Derby Users mailing list archive at Nabble.com.
Re: refresh JSP webpage when Derby DB is changed
As I understand it WebSocket is no longer part of the HTML5 spec, but its own separate spec.. And only Chromium currently supports it (I think).. WebSockets would, however, be much more preferable if you have strong control over the client browser(s).. but the polling - which is absolutely very brute force and inelegant - will work in any browser from the last 4-5 years.. On Feb 12, 2010, at 4:01:54 PM, Erin Drummond wrote: There IS a way to push data to the client, and I am using it successfully right now. It's called WebSocket and its part of HTML5, but only a few servers and browsers support it at the moment. Jetty 7 is one such server, and apparently later versions of WebKit and Gecko support it on the browser side (im not sure since my WebSocket client is a Java application which I wrote myself). Otherwise you can use Bayeux/Cometd to do long polling which simulates server push (its horridly complex compared to WebSockets depending on what you want to do with it, but it is much more widely supported) Erin On Sat, Feb 13, 2010 at 8:49 AM, Kristian Waagan kristian.waa...@sun.com wrote: Ronald Rudy wrote: This isn't really a Derby question, it's more of a web/Javascript question. There is no way to push data to a client. The request always originates on the client. That said, IF you are so inclined you can use Ajax type calls to poll a servlet on the server on a regular interval to check for updates. It would still be polling, though. Not event-based. Hi, While the original request has to originate from the client, you don't have to have the client poll on regular intervals - you can use something like long poll or streaming to basically get an event-based system. Note that this requires some software on the server side, and as most things these techniques have their challenges. Besides from the link already mentioned, you can have a look at Atmosphere ( https://atmosphere.dev.java.net/ ) and maybe post a question there or on a similer mailing list / forum. Hope this helps, -- Kristian I would look at prototype if you want to start leveraging Ajax. http://www.prototypejs.org/ It's a good place to start. I would be very careful about having JS continuously polling your server though. If you have lots of clients you will end up with lots of requests to handle. That code has to be very efficient. On Feb 12, 2010, at 11:17:22 AM, albertkao wrote: The goal is to refresh a JSP web page on a web browser when the Derby DB on the server is changed. The rate of database change is 1-10 times per hour. The record size is about 1000 bytes. The user use the browser to modify the data and write back to the Derby DB. The web server is tomcat. I am thinking of comet programming - pushing data from the server to client when the Derby DB is changed. Is that a good idea? How to do that with javascript or java? Any sample code or tutorial? -- View this message in context: http://old.nabble.com/refresh-JSP-webpage-when-Derby-DB-is-changed-tp27565891p27565891.html Sent from the Apache Derby Users mailing list archive at Nabble.com.
Re: refresh JSP webpage when Derby DB is changed
Well, websockets will not work if your clients come from corporationsas they usually deploy proxies with disallowed HTTP CONNECT. But as many said this is not really Derby topic. Just my EUR 0.02. On Fri, Feb 12, 2010 at 10:21 PM, Ronald Rudy ronchal...@gmail.com wrote: As I understand it WebSocket is no longer part of the HTML5 spec, but its own separate spec.. And only Chromium currently supports it (I think).. WebSockets would, however, be much more preferable if you have strong control over the client browser(s).. but the polling - which is absolutely very brute force and inelegant - will work in any browser from the last 4-5 years.. On Feb 12, 2010, at 4:01:54 PM, Erin Drummond wrote: There IS a way to push data to the client, and I am using it successfully right now. It's called WebSocket and its part of HTML5, but only a few servers and browsers support it at the moment. Jetty 7 is one such server, and apparently later versions of WebKit and Gecko support it on the browser side (im not sure since my WebSocket client is a Java application which I wrote myself). Otherwise you can use Bayeux/Cometd to do long polling which simulates server push (its horridly complex compared to WebSockets depending on what you want to do with it, but it is much more widely supported) Erin On Sat, Feb 13, 2010 at 8:49 AM, Kristian Waagan kristian.waa...@sun.com wrote: Ronald Rudy wrote: This isn't really a Derby question, it's more of a web/Javascript question. There is no way to push data to a client. The request always originates on the client. That said, IF you are so inclined you can use Ajax type calls to poll a servlet on the server on a regular interval to check for updates. It would still be polling, though. Not event-based. Hi, While the original request has to originate from the client, you don't have to have the client poll on regular intervals - you can use something like long poll or streaming to basically get an event-based system. Note that this requires some software on the server side, and as most things these techniques have their challenges. Besides from the link already mentioned, you can have a look at Atmosphere ( https://atmosphere.dev.java.net/ ) and maybe post a question there or on a similer mailing list / forum. Hope this helps, -- Kristian I would look at prototype if you want to start leveraging Ajax. http://www.prototypejs.org/ It's a good place to start. I would be very careful about having JS continuously polling your server though. If you have lots of clients you will end up with lots of requests to handle. That code has to be very efficient. On Feb 12, 2010, at 11:17:22 AM, albertkao wrote: The goal is to refresh a JSP web page on a web browser when the Derby DB on the server is changed. The rate of database change is 1-10 times per hour. The record size is about 1000 bytes. The user use the browser to modify the data and write back to the Derby DB. The web server is tomcat. I am thinking of comet programming - pushing data from the server to client when the Derby DB is changed. Is that a good idea? How to do that with javascript or java? Any sample code or tutorial? -- View this message in context: http://old.nabble.com/refresh-JSP-webpage-when-Derby-DB-is-changed-tp27565891p27565891.html Sent from the Apache Derby Users mailing list archive at Nabble.com.
Need help in designing secure database application
The use case is as follows. The application uses embedded derby. The information in the database needs to be secured. Users should not be able to list tables and table columns or get the data using select statements. My original thought was to implement the application logic as stored procedures, create a user in the database and give this user (who is not a database owner) the execute permission on stored procedures. Java application will use the CALL statements only and not select statements. I need to use connection authorization and SQL authorization both. In the JAva program, user name and password will be used to connect to the database. My problem is, if I start the database with user name and password, this user cannot shutdown the database as he is not the database owner. I don't want to use the database owner name and password in the Java program as user can decompile the Java program and get the database owner name and password. In short, here is what I am trying to achieve: Create and encrypt database with database owner name and password. Create user in the database with user name and password Grant Execute permission to user on stored procedures In the Java program, use user name and password to start the database Use Call statements to execute business logic Shutdown the database when done. I am not sure how to proceed. Any guidance in implementing will be appreciated. -- View this message in context: http://old.nabble.com/Need-help-in-designing-secure-database-application-tp27572103p27572103.html Sent from the Apache Derby Users mailing list archive at Nabble.com.
Re: Need help in designing secure database application
Hi Tushar, You are describing a difficult task. One approach is to encrypt data before they are stored in a database. In this case, you need a secure method creating and distributing keys. See http://www.bouncycastle.org/ for encryption libraries that are written in Java. HTH Charlie Tushar Kale wrote: The use case is as follows. The application uses embedded derby. The information in the database needs to be secured. Users should not be able to list tables and table columns or get the data using select statements. My original thought was to implement the application logic as stored procedures, create a user in the database and give this user (who is not a database owner) the execute permission on stored procedures. Java application will use the CALL statements only and not select statements. I need to use connection authorization and SQL authorization both. In the JAva program, user name and password will be used to connect to the database. My problem is, if I start the database with user name and password, this user cannot shutdown the database as he is not the database owner. I don't want to use the database owner name and password in the Java program as user can decompile the Java program and get the database owner name and password. In short, here is what I am trying to achieve: Create and encrypt database with database owner name and password. Create user in the database with user name and password Grant Execute permission to user on stored procedures In the Java program, use user name and password to start the database Use Call statements to execute business logic Shutdown the database when done. I am not sure how to proceed. Any guidance in implementing will be appreciated.
Re: Need help in designing secure database application
Hi Charlie: Thanks for the quick response! I think I can use the encrypt=true flag when database is created. This will prevent user from opening the database files in OS and dumping them to see data. Somehow I need to protect the data structures (tables/relationships etc) in the database. Charlie Kelly wrote: Hi Tushar, You are describing a difficult task. One approach is to encrypt data before they are stored in a database. In this case, you need a secure method creating and distributing keys. See http://www.bouncycastle.org/ for encryption libraries that are written in Java. HTH Charlie Tushar Kale wrote: The use case is as follows. The application uses embedded derby. The information in the database needs to be secured. Users should not be able to list tables and table columns or get the data using select statements. My original thought was to implement the application logic as stored procedures, create a user in the database and give this user (who is not a database owner) the execute permission on stored procedures. Java application will use the CALL statements only and not select statements. I need to use connection authorization and SQL authorization both. In the JAva program, user name and password will be used to connect to the database. My problem is, if I start the database with user name and password, this user cannot shutdown the database as he is not the database owner. I don't want to use the database owner name and password in the Java program as user can decompile the Java program and get the database owner name and password. In short, here is what I am trying to achieve: Create and encrypt database with database owner name and password. Create user in the database with user name and password Grant Execute permission to user on stored procedures In the Java program, use user name and password to start the database Use Call statements to execute business logic Shutdown the database when done. I am not sure how to proceed. Any guidance in implementing will be appreciated. -- View this message in context: http://old.nabble.com/Need-help-in-designing-secure-database-application-tp27572103p27572272.html Sent from the Apache Derby Users mailing list archive at Nabble.com.
Need help with an sql query
Hi, I need help with an sql query that I think involves using the CASE statement. The problem description is that a table say 'table1' has three fields viz. firstname, middlename, and lastname. The first and the third fields are mandatory, and when no value is given for the 2nd filed, an empty string is inserted by default. Now, I want to seach on the combination of these three fields such that I can specify the seach string as 'abc d%' where abc is the firstname and 'd' could be either middlename or lastname. I wrote the following sql statement, but the derby thew an exception. The sql statement is: select firstname || case when length(middlename) = 0 then '' else ' ' || middlename end || ' ' || lastname as name from studentmaster where name like 'abc d%' In the above statement, I have tried to give the name 'name' to the combined filed of three columns. I hope the above description makes sense and someone is able to help me out. Thanks, Dinesh The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/