We have web based application (Oracle DB, Weblogic middle tier) and a applet based application running on the browser.
We have a requirement to Load images from the database (stored as blob) to the client browser and the users can do the lookup on images when needed.
We need this to perform well, so there is no delay for the user experience. We have 2 options:
1. Load the images from the database to the Application Server and keep it. When the client request from the browser comes, download it from the application server.
2. Load the images (asynchronosly) when the user logs into the application and download them to the Client machine? Is this possible? Especially give that it is stored in the database as binary objects? And then load for the user from the client box itself, upon request.
If 2nd option is possible, which once is recommended?
I am trying to write a specific byte sequence to a specific memory location on a removable storage drive. Does Java allow me a way to do this? I know the dangers in accessing memory, but the memory location of the data that will be written will never change.
I am new to Android. I have byte array of size 10. I am passing the Decimal values (131 - 140) to byte array. But while printing I get Negative (-) values with decreasing order .
How can I get same value as positive values?
Or How can I store positive value e.g. 131 as byte array element.
Please not my requirement is array must be ByteArray only
I have a checksum function that is suppose to read IPV4 packet and return a short integer value. The IPV4 packets are stored in a byte array. I am having trouble storing the first 8 bits and second 8 bits of the short integer into the byte arrays especially when they have leading 1s. For example, if my checksum returns 5571 (binary = 0001 0101 1100 0011) The first 8 bits is suppose to represent 195 but when I try to assign a larger integer type to a btye the information gets sign extended. The 195 turns into -61. I tried using bit addition like array[10] = array[10] & 0xff, but the result remains the same.
public static short checksum(byte [] a, int length) { short sum = 0; long data; int i = 0; while(length > 1) { data = (((a[i] << 8) & 0xff00) | ((a[i + 1]) & 0xff)); sum += data;
I and a friend are working with a project to create a file system, who manages a secondary memory simulated as a byte array in Java. We want the file system to be a hierarchical tree structure like in UNIX.
We have come quite far, but the paths are not handled correct. I seem to have mistaken the relative folder ./ for the root folder, but it should mean "working directory folder", ie, where I stand now. That is, if I stand in /dir1 as my "working directory" and make mkdir ./dir2 then should dir2 end up as subfolder in dir1. But with me it appears in the root.
I'm just putting together a little 'horse racing' program while I'm learning Java, and I have a class called Race that creates an array list of thorougbred horses called field, and asks the user to enter then names of the each horse in the field, with a maximum of 14 horses. The problem occurs with the current code that I have:
import java.util.*; public class Race { RaceHelper helper = new RaceHelper(); ArrayList<thoroughbred> field = new ArrayList<thoroughbred>(); public void setField() { //enter the horses in the race and determine the size of the field
[code]....
the statement of the index position and current size was for me, so I could see what was going on.What I don't understand is the while loop. not that the class doesn't compile and run (you can see that it does), it's the output. Why does the <= sign allow one more entry and increase the size of the field to 15?
Less than or equal to 14 should give a maximum field size of 14, right, With the starting object at index position at zero and going up to 13, for a total size of 14 thoroughbred objects if I just use while (field.size()<14) or a for loop, then the output is fine; it allows a max of 14 entries and prints the results. I thought it had something to do with the size being zero based, but that doesn't seem to matter -- unless it does matter and I'm missing it. why the comparison I'm using produces this output? a field of 14 horses shouldn't matter whether it's zero or 1 based, as long as the size of the field is 14, so why the extra entry with this while condition?
I designed a Java desktop application (i.e the app runs on local computer), everything is fine until when I compiled the program and wanted to run it on another computer then it tell me "java.sql.SQLException: attempt to write to only read database".
I want to write the image file from a database to disk by using a queue. I can write these images on disk from the result set. I am wrong in the following code? I get: "trying to write to disk: Closed Connection"
{code} public class ExtractPicture implements Runnable{ private BlockingQueue<InputStreamMessage> queue; public ExtractPicture(BlockingQueue<InputStreamMessage> queue){
I need to retrieve an image from the MySQL DB and display it in my JSP. The code below retrieves and displays the image with success. But, an exception is thrown:
SEVERE: Servlet.service() for servlet [jsp] in context with path [/FileFinalText] threw exception [java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause java.lang.IllegalStateException: getOutputStream() has already been called for this response
[code]...
how can I resolve the cause with the getOutputStream() and prevent this exception to occur?
I used the PLPDF software to generate a blob in PDF format in PL/SQL. I can open it in a browser but I would rather send it directly to a printer from PL/SQL.
I know I can use tools like BI and Jasper but I want this particular solution to be 100% database solution.
I was wondering of I can use JAVA in Oracle to send the blob to a printer.
So here is a method i wrote for the first part for initializing an array:The question was, "write a method which initializes a 2D target array (assuming all other classes have been imported and given), and all targets should be stationary."and this was my method i wrote:
public void initializeTargetArray(Target[][] targets) { int row = targets.length(); int col = targets[0].length;
for(int i = 0; i < row; i++) for (int j = 0; j < col; j++) targets[i][j] = new Target(Target.STATIONARY, false); }
Now my question how do I initialize an array similar to the method above for a different question?
Quote Part b Write a method which initializes an array (You can assume that the 2D array itself (but not the Target objects inside) is already initialized), where the game level stage is now set: Game level 1 - all targets are stationary, Game level 2 - For even numbered rows, targets at even numbered columns are stationary, targets at odd numbered columns are movable. For odd numbered rows, targets at odd numbered columns are stationary, targets at even numbered columns are movable. Game Level 3 - All targets are movable.
public void initializeTargetArray(Target[][] targets, int gameLevel) { //*** Finish this method. ***//
Write a program to create an integer array of size 20. Then, the program should generate and insert random integers between 1 and 5, inclusive into the array. Next, the program should print the array as output.
A tremor is defined as a point of movement to and fro. To simulate it, the program will generate a random number between 0 and 19, which represents the location in the array (i.e. index number). Then, the 3 numbers to the left and right of this location should be reset to the value 0. If there isn't 3 numbers to the left and right you may assume a lesser number depending on the boundaries of the array.
Then, the final array should be printed as output. There is no user input for this program.Your program must include, at least, the following methods:
-insertNumbers, which will take as input one integer array and store the random numbers in it. -createTremor, which will generate the random number as the location and return it.
I have this working manually, but need creating this from a DB Connection and populating the Array with the results. I just need populating "DestinationItem[]" from the SQL below
DestinationBean.java // Manual Array works but I need this to be populated from DB using the below Query and DB Connection info. private DestinationItem[] destinationResults = new DestinationItem[]{ new DestinationItem("58285", "Dodge Grand Caravan"), new DestinationItem("57605", "Dodge SX 2.0"), new DestinationItem("58265", "Chrysler 300 Touring")
i have to "Write a method called addToOverThirty which takes the array nums3 as a parameter. It adds 1 to all numbers that have a value greater than 30 in the array.
Add a call to the addToOverThirty method, then display a message telling what the output is followed by the results For example:The nums3 array after adding 1 to all numbers greater than 30 is10 6 15 and so on (check with the values you assigned to nums3)"its pointless because we were told not to make the array have a number over 30.
import java.lang.*; import java.util.*; public class LastProject public static void main(String[] args) { int nums1[] = new int[15]; int nums2[] = new int[15]; int nums3[] = {5,2,15,8,26,22,1,29,4,23,30,11,19,6,24};
Is there an advantage in using byte instead of int beyond the space savings? In my program, I'll never need close to the max value of a byte, let alone int, so it seems like a waste to make my primitives ints.
I stored an image into MySQL database using swings and hibernate but I am struggling to retrieve that image from MySQL database and display same image in the jTable cell and same as on jLabel whatever I retrieve from the database using swings and hibernate .
I need to send a byte array across a network. I know how to do this. (server->client)
byte[] myArray = new byte[]{0,1,2,3,4,5,6,7,8,9}; DataOutputStream.write(myArray);
... and I know how to receive it.
byte[] myArray = new byte[10]; DataInputStream.read(myArray);
When I send over one of these arrays, it ends up stopping storing values in the array when only about half the array is received, even though the array is sent from the server all at once. This results in the receiver's array, in this case, being something like {1,2,3,4,0,0,0,0,0,0}.
I can easily solve this - and already have - by simply adding a loop onto it and waiting for the bytes to all be received, as the method returns the amount of bytes actually read.
I am simply wondering if there is a better solution to this, as the current solution isn't that elegant. Did I do something wrong to cause only a part of the array to be sent first? Would it be better to use DataInputStream.readByte() to read off the bytes one by one rather than an array at once, and then store them in an array afterward? Would this cause a performance decrease as each byte is read individually? (I'm sending an array of several million bytes)