|
Hi, I'm new in Java and have the following task to do:
I have some data stored in gzip byte array and I have to insert it into MySQL database.
I'm using DBCP (Apache Tomcat 6.0.20) not JDBC.
I tried the following code:
PreparedStatement pstmt =(PreparedStatement)con.prepareStatement("insert into test_tb (id, data, compressed_data) values(?, ?, ?)");
pstmt.setString(1, cl.getOwner());
pstmt.setString(2, "");
pstmt.setBytes(3, cl.getCompressedData());
int i = pstmt.executeUpdate();
but this didn't work because of Cast Exception - java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement cannot be cast to com.mysql.jdbc.PreparedStatement
What is the right way to do it?
Thanks.
|
|
|
|
|
Declare pstmt as java.sql.PreparedStatement, not com.mysql.jdbc.PreparedStatement.
|
|
|
|
|
Hi,
I've a diamond shape image inside a label, inside that image(label) I want place one more label(image name). Is it possible?
Is it possible to resize the image dynamically by using mouse pointer?
Thanks in advance
Regards,
Janaki
|
|
|
|
|
no, it is not possible to place a JLabel[^]in another JLabel.
You should try to use JPanel[^].
greets
Torsten
I never finish anyth...
|
|
|
|
|
Hi,
Can you give me a forth to handle this?
Is it possible to resize?
Thanks in advance.
regards,
Janaki
|
|
|
|
|
public class Interference extends Thread {
String name;
static boolean isZero = true;
static int counter = 0;
public static void main(String arg[]) {
MyThread m = new MyThread();
m.setName("Important Thread");
m.start();
synchronized(m){
try {
System.out.println("Waiting for " + m.getName() + " to Complete....");
m.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("Main Work Started");
System.out.println("Hello");
}
Interference(String nameString) {
name = nameString;
}
public void run() {
System.out.println(name + " Started....");
for(int i=0; i<100000000; i++) {
if(isZero) {
isZero = false;
counter++;
} else {
isZero = true;
counter--;
}
}
System.out.println(name + ": " + counter);
}
}
class MyThread extends Thread
{
public void run()
{
System.out.println(Thread.currentThread().getName()+" : Let me finish first !");
Interference inter = new Interference("NEW");
inter.start();
try {
inter.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
for(int i =0;i<1000;i++){}
System.out.println(Thread.currentThread().getName()+" : OK! do your work now");
}
}
The above code demonstrates a wait and notify scenario but I have not notified the object after MyThread's work finishes. I'm amazed that without notifying, how the wait() breaks. can anybody explain me.
|
|
|
|
|
If you read the javadoc for wait, you will see that you can get what are called "spurious wakeups".
begin quote:
As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:
synchronized (obj) {
while (<condition does not hold>)
obj.wait();
...
}
end quote
I have no idea how a spurious wakeup can actually happen but at least it is documented behaviour.
|
|
|
|
|
Hello Friends
I am creating a jar file and I crated one bat file in which specifying the heap size and calling that jar file and its working fine in Windows XP.But when I use same bat file in Windows7 then it is now working .Its just opening command panel and closing,and my application is not opening.
Any ideas to work that in Windows7?
Here is bat file:
@echo off
java -Xms512m -Xmx1024m -jar sample.jar
Regards
Yogesh
|
|
|
|
|
It may be that your path (or some other variable) is not set correctly. Try adding a pause command at the end of the .bat file to see if that gives any further information.
It's time for a new signature.
|
|
|
|
|
After ur Suggestion I tried pause command and found tht It is saying tht java command doesnt found.Then I checked that there are two folder in c are System and another sysWow64(tht is for 32 bit) and java is installed here in sysWow64.
And command prompt is opened thru C->windows->system32.
Any Other Ideas??
While Installing also,I installed 64 bit jre and in program files not in programfilesx86.
Regards
Yogesh
|
|
|
|
|
yogeshs wrote: Any Other Ideas?
Yes, set your Path variable so the batch file can find the java command. This is normal procedure when using batch file processing.
It's time for a new signature.
|
|
|
|
|
can any one help me code for any distributed hash table implementation ....
|
|
|
|
|
Try doing the work yourself, see here[^] for some assistance.
It's time for a new signature.
|
|
|
|
|
Hey,
Anyone fancy earning a little bit of money by adding a highscore feature to my JAVA ME mobile game. Plus maybe a few other little bits and pieces.
Cheers
|
|
|
|
|
Rent A Coder[^] is what you're looking for.
Kristian Sixhoej
"I have noticed even people who claim everything is predestined,
and that we can do nothing to change it, look before they cross the road." - Stephen Hawking
|
|
|
|
|
hey, i want to learn gui under java platform,
i've some experience with winforms, how different java swing from it ?
also i'll be greatfull for some advice for good ide which can be worked with java swing
I was thinking that eclipse is capable for it, but it's seems that i was wrong.
thanks
|
|
|
|
|
igalep132 wrote: i've some experience with winforms, how different java swing from it ?
Very different. Be prepared for a steep learning curve.
igalep132 wrote: I was thinking that eclipse is capable for it, but it's seems that i was wrong.
Eclipse is capable of Swing programming. I think what you mean is that by default it does not have a visual designer. If you go to the Eclipse website you will find that there are some plugins that provide this. Otherwise, if you are using Eclipse you will have to code up the UI by hand (which is what many Swing programmers prefer, anyway).
For a beginner, possibly NetBeans is a better choice as it includes a pretty good GUI designer. The downside with that is that you won't really learn how Swing works because NetBeans is generating the code for you.
Swing is a big, powerful toolkit but there is a lot to learn and people coming from a VB background in particular often struggle with it at first. I would definitely recommend looking for a good book to get you started on the right track. A search on Google should give you a list of suggested books.
|
|
|
|
|
hey, thanks for the answer...
David Skelly wrote: If you go to the Eclipse website you will find that there are some plugins that provide this.
do you have any advice for a preferred one ?
David Skelly wrote: Otherwise, if you are using Eclipse you will have to code up the UI by hand (which is what many Swing programmers prefer, anyway).
and if so, how can i test it ? (i assume that some swing plugin required for see swing interface...)
David Skelly wrote: The downside with that is that you won't really learn how Swing works because NetBeans is generating the code for you.
and there is no possibility to change the code ?
David Skelly wrote: I would definitely recommend looking for a good book to get you started on the right track
any suggestion ?
thanks again
|
|
|
|
|
David is absolutely right....I myself is new to Java and, is learning java in my university and we are using Notepad++ to create GUIs for java applications, would you believe this?? There is alot of pain in this technique....lolzz. But congratulations, if you adopt this technique, you will have very good idea what is going on behind the scenes.
|
|
|
|
|
it's remind me my early days of first year while i was using with jcreator
|
|
|
|
|
igalep132 wrote: do you have any advice for a preferred one ?
No. I don't use them so I can't recommend one.
igalep132 wrote: i assume that some swing plugin required for see swing interface
No, sorry if I wasn't clear. Eclipse is capable of running Swing, because it is a standard part of Java. What Eclipse is missing is a visual designer, that lets you build a screen by dragging and dropping components. For that you need a plugin, but Eclipse is perfectly capable of compiling and running Swing code without any plugins.
igalep132 wrote: and there is no possibility to change the code ?
Yes there is, but (a) it uses a special layout manager (GroupLayout) which is not really intended to be coded manually so might be a bit tricky and (b) as soon as you change the code manually you will not be able to use the visual designer any more.
As far as books goes, you could try the Sun tutorial which is a decent starter and covers the basics pretty well:
http://www.amazon.com/JFC-Swing-Tutorial-Guide-Constructing/dp/0201914670/ref=sr_1_12?ie=UTF8&s=books&qid=1271752168&sr=1-12[^]
There are others. Search Google and see what comes up.
|
|
|
|
|
hello guys....im trying to close the JFrame with a JButton on it. Im unable to make a logic...will it be useful to make an inner class for WindowAdapter and use it in the actionPerformed() function (used by JButton's ActionListener) ??
|
|
|
|
|
Hello Friend,
I dont no more in java, but got a job to do.
can anyone tell me alternate of MouseTranslate for paning(moving object) in viewer on mouse first button. as MouseTranslate is a Java3D behavior object that lets users control the translation (X, Y) of an object via a mouse drag motion with the third mouse button.
i want same in first button
plese help me
Thanks
Shafiq
|
|
|
|
|
Hello Friends
I am creating a submenu under menu and that subMenu having an array of MenuItems(Suppose 5).And When I click on any one of its 5 subMenuItem,I want to delete that SubMenuItem from that subMenu.I know that there is function like remove with different parameters like position,component but on the click of that submenuitem,I only get its event,and tht event produces the name of tht subMenuItem but removeItem doesnt take any parameter like string.
How can I delete that particular clicked SubMenuItem?
Thanks IN Advance.
Regards
Yogesh
|
|
|
|
|
Project I am working on has a courtesy Weather.com Page. The intent is to display the client side weather conditions--not the server.
The HTML code from Weather.com looks like this:
<script type="text/javascript">
</script>
<div id="wx_module_7847" style="padding-left: 225px;" >
if (!document.cookie && document.cookie != "") {
Alert("Cookies must be enabled in Internet Explorer to use Weather.com<br />in the Aloha Manager's Desktop.")
}
if (!document.amdczip && document.amdczip != "") {
createCookie('amdczip', '40212', 365)
}
var wczip = readCookie('amdczip')
document.write('wczip')
<a href="http://www.weather.com/weather/local/34979">Your City's Weather Forecast, AA (11111)</a>
</div>
<script type="text/javascript">
/* Locations can be edited manually by updating 'wx_locID' below. Please also update */
/* the location name and link in the above div (wx_module) to reflect any changes made. */
var wx_locID = '08043';
/* If you are editing locations manually and are adding multiple modules to one page, each */
/* module must have a unique div id. Please append a unique # to the div above, as well */
/* as the one referenced just below. If you use the builder to create individual modules */
/* you will not need to edit these parameters. */
var wx_targetDiv = 'wx_module_7847';
/* Please do not change the configuration value [wx_config] manually - your module */
/* will no longer function if you do. If at any time you wish to modify this */
/* configuration please use the graphical configuration tool found at */
/* https://registration.weather.com/ursa/wow/step2 */
var wx_config = 'SZ=300x250*WX=FHW*LNK=SSNL*UNT=F*BGI=spring*MAP=null|null*DN=askbillbradley.com*TIER=0*PID=1177763389*MD5=be2899d91f6feddef8216cd03ec459a7';
document.write('<scr' + 'ipt src="' + document.location.protocol + '//wow.weather.com/weather/wow/module/' + wx_locID + '?config=' + wx_config + '&proto=' + document.location.protocol + '&target=' + wx_targetDiv + '"></scr' + 'ipt>');
</script>
The VAR var wx_locID can be changed under license. However, I am having a difficult time requesting a Zip Code using a form/input, saving it as a cookie for future use, retreiving that cookie and assigning its value to the var wx_locID.
It var exists inside a script. I cannot modify that script per weather.com terms and conditions, but I need to pass the zipcode to it.
Any assistance would be appreciated.
|
|
|
|