David Wong

Greenhorn
+ Follow
since Dec 31, 2007
Merit badge: grant badges
For More
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 David Wong

Originally posted by Jeanne Boyarsky:
David,
Blobs are binary data whereas Strings are character data. A Clob maps to a String. Or a Blob can map to an array of bytes. Can you clarify a bit?



Thanks for so helpful information.But I have a field in Blob type in my database. It is like a web blog, I want this Blob field can store the text and photos as well. In fact I wanna all things from the client submited. I think since the Blob are binary data, so it can handle any type of data, besides string. and I confused by how converting this.

Consider this, I wrote a blog today, the content of this article is rich enough, it contains photos and words and other ASC codes like a carriage return symbol("\n"). I have all of this blog putted into the Blob field. That is what I am thinking about.

All information in a computer represented by binary data, so, string can trasform bytes data, but I search the API about Clob/Blob, they are interfaces and can be instantiated only by invoking JDBC methods, like ResultSet.getBlob()/getClob();

To sum up, I do not know how to make a Blob type take the client data.
I want to assign a string value to a Blob object.

Obviously there are many methods of Class can do this under java.sql package,but now the rule is changed, if there is a way out to get done this without the JDBC the ResultSet.getBlob(). If I use a hibernate and Struts,I get a string from view layer and have this value stored into the Transient object.

Thanks in advance!
Hi, I wanna use a command to run a JAVA application like C/C++, for instance, under the windows comand line I write instructions as below:

c:\>F:\MyVcApplications\test.exe

how can I run a java app like that?

c:\>java F:\MyJavaApplications\Test

I know the implementing as above is impossible. There may be a package can resolve this problem, write a line in JAVA code at head: package myjavaapplications; and run it like java myjavaapplications.Test

But this only resolved a part of the problems. How could I find a certain disk, F:\. Maybe you say just change the directory using cd instruction. But the point is I will implement the things in a program like this:

ProcessBuilder pb = new ProcessBuilder();
pb.command(/*the instructions will be here*/);

I think one way that use cd command in pb.command(), But I really prefer a concise way, this is little diffuse, I won't try it anyway.Please help me.

Thanks and wishes with the best.
15 years ago
As the topic, I attempt to use ProcessBuilder to handle a subprocess, finally it works.

But I do wanna more feature of the subprocess, for instance, the time of subprocess running, the memory a subprocess consumed. If the running time or consumed memory of this subprocess exceeds the range that one customized, then destroy it immediately.

Is that possible, or else only jni can do it? thanks in advance.
15 years ago
Now I have more than one hundred thousand records need to sort, what is the best algorithm can work at a high performance.
name math english total ranklist
jack 80.00 90.00 170.00 2
tom 95.00 90.00 185.00 1
jerry 50.00 40.00 90.00 3
I want to sort ranklist dynamically,when a new thing was added, then sort it ,but pay attention please, there are one thousand records here at least. Who can find a answer for this, show me the way, thank you in advance and my best wishes.

David
15 years ago
How can I print out the Exception on the jsp? I use ExceptionHandler to handle the exceptoins, and I want them can be printed on jsp pages. Is that possible?

Thanks and my warmest regards.
15 years ago
the question as the topic.
Thanks in advance and wish the best.
hello,i want to learn jsp,any classic books for a beginner?it's better easy to go on with.
15 years ago
JSP
For more details and orderliness,here gives items to show what I want a program A could do these:



1.Supervise how much memory the program B consumed.If the program B was running and allocated memory exceeded the speciafied number,then report back to screen.


2.Restrict the priority of accessing the files out of its directory/folder to program B.Avoid running the dangerous code like system("reboot") from programs.


3.Kill the Process B if there includes any code lead to never finish running.e.g while(1){}.Of course,if a legal program runs out time will be also killed.


4.How can I capture these above return messages,e.g Runtime error,stack overflow,Memory Limit Exceed.So much information just for users.



Note:This is very similar to a online judge system.



Thanks In Advance.
15 years ago

Originally posted by Nicholas Jordan:
What are you trying to do?

study Java first because of it's rich collection of computer science, then study C/C++ as an adjunct when and if you have the extra time.

How many languages do you know right now?

Welcome to Java Ranch Saloon



thanks for information.
In fact I am trying to build a web project:The c/c++ code is submitted and forwarded to the server from client browser.Then I think there would be a method in java can invoke and run c/c++ compiler,after compiling then get compiler information if something was wrong in code that can't pass the compiling.In a word,that will be an online judge system.

I know c/c++ a little.I just want to use Java to carry out this question.I am studying Java now.

thanks again.
15 years ago
I want to use java for compiling c/c++ code,and the compiled infomation should be caught,e.g overflow...Is there a way to carry out this?I used getRuntime().exec("gcc .c -o .exe"),on this condition there was no information from compiling time.

How can i use java to control that one executable program(e.g .exe) not to access the files out of this folder/directory,and assure the program not
to performance anything in high-risk command like system("reboot") or while(1) fork();Is that possible for java?

If c/c++ could be better to do this,welcome as well.


thanks so much!!!
15 years ago
I want to use java for compiling c/c++ code,and the compiled infomation should be caught,e.g overflow...Is there a way to carry out this?I used getRuntime().exec("gcc .c -o .exe"),on this condition there was no information from compiling time.

How can i use java to control that one executable program(e.g .exe) not to access the files out of this folder/directory,and assure the program not
to performance anything in high-risk command like system("reboot") or while(1) fork();Is that possible for java?

If c/c++ could be better to do this,welcome as well.


thanks so much!!!
15 years ago
are there two strategies of mapping for <one-to-one/> ?one is primary key mapping strategy other is foreign key mapping strategy.what's the advantage in each of them?

if i have a construction of db below:

table a
id int primary key
name varchar

table b

id int primary key
a_id int foreign key(a_id) references a(id)

how could we use the two strateies to get one a to one b.what are the differences?

thanks very much!!
thanks for information.thank you everyone pays your passion.
15 years ago
If private member variables can be inherited from the base class?I read some books describes as NO,they thought one class should be inherited all methods and attributes from the base class,otherwise there is an entire duplication from the base class in the derived class.I think the derived class has a copy of based class,it just can not be accessed when the base class member variables specified as private?

public abstract class PhoneCard {

private Long id;
private String password;
private Double balance;
private String digits;

public PhoneCard() {}

public PhoneCard(Long id,String password,Double balance,String digits) {
this.id = id;
this.password = password;
this.balance = balance;
this.digits = digits;
}
//...
}
public class TwoHundredCard extends PhoneCard {

public TwoHundredCard() {}

public TwoHundredCard(Long id,String password,Double balance,String digits) {
super(id,password,balance,digits);
//methods was inherited from base type,but the private fields was not
}
//...
@Override
public void priceCount() {
System.out.print("connection successful established ...");
this.balance -= 0.5;//balance can't be accessed,
//but there is a whole copy of PhoneCard

}
}

yours friend!
15 years ago