Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!

Brian Mozhdehi

Ranch Hand
+ Follow
since Aug 17, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Brian Mozhdehi

actually, you have me on to something - thanks again
9 years ago
Hi - sorry, I haven't asked that many questions, mostly answered them. I will pay attention to the code tags. In the meantime - I dont think this is a tutorial level issue, its really whats different between 1.5 and 1.6. So - thank you for your answer, I appreciate your time. But anyone else reading that is willing to tolerate my error on the code tags - any help would be appreciated. Thanks much.
9 years ago
Hi,

I have an application that uses JFrame and JInternalFrames. When I use JRE 1.5, the JINternalFrame iconify using the code I have when the icon selection is made on the window. In 1.6 it does not work and I cannot determine what has changed.

Below is a new application I wrote with condensed code that illustrates the issue

Here is the FRAME

package com.orion.client;

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

public class MainClass extends JFrame
{
public MainClass()
{
this.addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e){System.exit(0);}});

try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}
catch(Exception e){}

JPanel mainPanel = new JPanel();
mainPanel.setBackground(Color.white);
mainPanel.setPreferredSize(new Dimension(800, 600));
mainPanel.setBorder(BorderFactory.createEtchedBorder());

getContentPane().add(mainPanel);

pack();
setVisible(true);

getLayeredPane().add(new TestInternalFrame());
}

public static void main(String[] args)
{
new MainClass();
}
}


Here is the JINTERNALFRAME

package com.orion.client;

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

public class TestInternalFrame extends JInternalFrame
{
public TestInternalFrame()
{
super();

setAutoscrolls(true);
setResizable(true);
setMaximizable(true);
setClosable(true);
setIconifiable(true);

JLabel aLabel = new JLabel("This is a Test Screen");
JPanel aPanel = new JPanel();
aPanel.setPreferredSize(new Dimension(200, 200));
aPanel.add(aLabel);

this.getContentPane().add(aPanel);

pack();
setVisible(true);
}
}

and attached is a screen shot of the result. I attempt to iconify the internal frame and the _ converts to two overlapped boxes and the screen doesnt iconify




9 years ago
Thank you for your help, very much appreciated. That makes sense.
9 years ago
I am struggling to get a String representation of a 4 byte array that represents an Integer (written from DataOutputStream). It seems that whenever one of the bytes results in a -127 value (HEX 0X81), when I convert the byte array to a String using new String(byte[]), a subsequent call to String.getBytes() converts the value -127 to 63.

I can share the complete code if needed, but I found I can reproduce this with a snippet as below

************************
byte[] bb = new byte[1];
bb[0] = -127;

String aString = new String(bb);

byte[] bb2 = aString.getBytes();
**************************

Inspecting the bb2[0] byte shows a 63 instead of -127.

Kind of an obscrue question I am assuming, but anyone have any ideas on how to solve this?

Thanks in advance for any assistance, much appreciated
9 years ago
Im pretty sure your issue is that you are in a result set, looping and creating new statement(s) and new result set(s) within the loop. Meaning, within rs.next(). Not to be "unhelpful" I didnt look super closely, but I think thats your issue. You cant do that.

If you need to retreive data, then use this data to retrieve something else in a loop, create two sections of code, one that retreives the criteria and stores it in say an ArrayList, then close and clean up your statements and result sets and start a new loop thru the ArrayList doing your second set of SQL. Be sure to clean up as you loop around each time.
You are not able to do this because the API doesnt allow it - being able to do so would pose a security risk to the associated application.

I presume you have the password already otherwise you wouldnt be able to connect in your code?
You may also call Statement.getResultSet() if you choose to use execute() and the statement produces a ResultSet. executeQuery() is a conveience method when running SELECT statements as you of course are looking for a Result set usually in this case.
Actually, the issue is not the connection (I have never seen the JDBC-ODBC bridge do that, BTW.). The issue is ps.executeUpdate

Try ps.execute();
Thanks much for this, much appreciated. I agree with what you are saying on the specification/entire URL. It isnt part of the specification I dont think. I may end up having to write directly to the stream. But at least I can try HttpClient and see what happens. Maybe I can "extend" to allow the variation. On a side note, this whole project is crazy - its a Canadian government thing, this is among their many requirements that make no sense
Hi - I need to use the HTTP 1.0 protocol for a web server I am trying to post to. In that, I need the request headers to send explicitly
POST <URL> HTTP/1.0.

When I use HttpURLConnection, I cant seem to find a way for it to send 1.0 instead of 1.1, i.e it sends HTTP/1.1. Also, it seems to send only the resource in the <URL> paramater, i.e for http://foo.com/bar it sends /bar when I need it to send http://foo.com/bar.

This requirement is being driven by a government server, so I cannot change it. Do I need to manually code the transmission of the request headers or is there a way to make HttpURLConnection do whats needed? Or is there another object that might work in place of HttpURLConnection?

Thanks much for any help.
Hi - I have a file coded in the native command language of the printer I need to print to. Its an Intermec Barcode printer and the file I have is in IPL language with all necessary data populated to print a barcode on the printer. I have this in file format bu of course can also get this as a string.

I want to send this string directly to the printer, i.e. as text direct to the printer. The printer is installed in Windows as a Generic/Text printer. When I use the print API, it forces me to define this as a type the printer supports, closest I can see is image/gif and then when I do this, the label does not print.

The data is correct because I can open a command prompt and type copy/b <filename> <printer> and it works fine.

Is what I am tying to do possible using the Java Print API? It seems like this forces the user into a series of steps defining document flavors other than just "printer command text", etc which I dont know but suspect is messing with my data prior to sending it. Is it possible to open a direct socket connection to a printer? Or do I have to use RunTime.exec and the copy command?

Any help would be greatly appreciated
11 years ago
I understand, OK, thanks again for answering, much appreciated.
12 years ago
OK, thanks much. Is that due to security or something like that?
12 years ago
Hi,

I have a servlet that is to reside on a server and its sole purpose is to forward any requests it receives to another servlet on another server. I have written the code below, which I know wont work because "context.getRequestDispatcher" is looking for a relative URL. My URL is on another machine though and I dont what I need to do differently to make that work.

Any help would be most appreciated. Thanks in advance....

ServletContext context = getServletContext();
RequestDispatcher dispatcher =
context.getRequestDispatcher("http://somemachine:8080/myapp/servlet/MyServlet");
dispatcher.forward(request, response);
12 years ago