Setting up internet access through proxy server
Today I had a trouble in my workplace when a client application, running through a terminal (DOS prompt), not reach the server hosted in the internet, this is because the company where I work use proxy.
After some tries I found two solutions to solve my access problem: first was pass as Java parameters the proxy's configurations.
$ java -Dhttp.proxyHost=serv -Dhttp.proxyPort=port -Dhttp.proxyUser=user -Dhttp.proxyPassword=pass ClassJava
-Dhttp.proxyHost = IP or host name of server proxy
-Dhttp.proxyPort = Proxy port
-Dhttp.proxyUser = User
-Dhttp.proxyPassword = Password
This way the class ClassJava will have access to internet through proxy server.
Another way, was insert the settings in own class:
public static void main(String[] args){
...
System.getProperties().put("proxySet", "true");
System.getProperties().put("http.proxyHost", "serv");
System.getProperties().put("http.proxyPort", "port");
System.getProperties().put("http.proxyUser", "user");
System.getProperties().put("http.proxyPassword", "password");
...
}
proxySet = Connect, or not, through proxy server
http.proxyHost = IP or host name of server proxy
http.proxyPortt = Proxy port
http.proxyUse = User
http.proxyPassword = Password
Using this resource you can set your application to access the internet through proxy server.
I hope help you. Bye!
Amarok’s playlist stop after play one music
Recently I had a problem like others Amarok's 2.1.1 users: It play only one music and stop.
To resolve this: Close Amarok, delete the file ~/.kde/share/apps/amarok/current.xspf and then restart Amarok.
Least worked to me and I hope that works for you too!
Until next!!
Saving files in BLOB table column of a data base
To insert a file, is it in any format, you need call the method setBinaryStream, implemented by PreparedStatement.
PreparedStatemente.setBinaryStream(int index, Inputstream is, int length);
In sample, we set a table called FILEthat contains BLOB column called BIN.
//Normal connection, as any JDBC connection
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@<IP>:<PORT>:<SID>","<USER>","<PASSWORD>");
//Reading the file and retrieving an InputStream
File file= new File("<COMPLETE_FILE_PATH>");
FileInputStream fis = new FileInputStream(file);
//Preparing statement
PreparedStatement ps = conn.prepareStatement("INSERT INTO FILE(bin) VALUES(?)");
//Passing InputStream and file length
ps.setBinaryStream(1, fis, (int)file.length());
ps.execute();
ps.close();
conn.close();
I used Oracle 8i to execute this sample. I haven't a MySQL/PostgreSQL/MS SQL Server in my dispose, then you'll responsible for testing in this data bases and send me the results, OK
Thanks! Until next time!
How to enable Telnet and TFTP Client on Windows 7
Like in Windows Vista, Windows 7 don't enable Telnet and TFTP Clients in installation.
To enable them, open Control Panel > Programs and Features > click Turn Windows features on or off in left side > enable Client Telnet and Client TFTP then click in OK.
I not tested in Windows Vista yet, but the process can be same.
See you soon!
The most used Unix commands for Windows
Have you thought about run commands like grep, chown, tail e su in Windows SO and can change command dir by ls?
Looking in internet for an alternative Win32 to command tail, I found UnixUtils. A compilation for Windows of most used commands in Linux/Unix.
You can download the ZIP file in SourceForge clicking here.
Bye!