NetBeans 7.2 is out!
Go grab it while it's hot. :)
New&Noteworthy page can be found here.
I hope you'll enjoy it as much as I do!
sreda, 25. julij 2012
ponedeljek, 23. julij 2012
com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException
If you get
com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2030][11211][4.13.80] A communication error occurred during operations on the connection's underlying socket, socket input stream, or socket output stream. Error location: Reply.fill() - insufficient data (-1). Message: Insufficient data.. ERRORCODE=-4499, SQLSTATE=08001
then this usually means you are using a connection pool to get connections to database and that connections in the connection pool are "stale".
What does stale mean?
You have connection pool started, connections created, but then database restarts. The connection you now get out of the connection pool are now stale and you have to restart the connection pool (close all connections and create new ones).
nedelja, 27. maj 2012
Sourcing .bashrc in non-interactive shell
This is a new post in a long, long time. A lot has happened since New Year. I'll post about that at a later date. :)
Now to using bash under Linux.
When you are running a bash session in a terminal you are inside of an interactive environment and you can edit .basrc and source it at any given time.
You source .bashrc like this:
source ~/.bashrc or . ~/.bashrc
Now, let's say you have a bash script that you want to run. You can run in in a terminal, but that is not the subject of this post. You can run it via a file manager, like Dolphin, thunar, ... or you can put a shortcut to it on your desktop.
If you want to source .bashrc in that script, it won't work, because running via file manager or desktop is running a bash script in an non-interactive environment. .bashrc notices that and does not do anything. In fact if you look at .bashrc you will find something like this:
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
at the beginning of you .bashrc.
But there is a solution for this. Put PS1='$ ' in your script before sourcing .bashrc.
Examples:
- run a terminal
- edit .bashrc and put
export TEST_TEXT='My test text' in your .bashrc
- make a new script test.sh:
#!/bin/bash
. ~/.bashrc
echo "TEST_TEXT = $TEST_TEXT"
read
- make it executable
chmod +x test.sh
- run it and you should get something like this:
TEST_TEXT =
- now source .bashrc and run the test.sh script
. ~/.bashrc
./test.sh
- and you get
TEST_TEXT = My test text
If you run this script via file manager you will always get TEST_TEXT =
Change the script to
#!/bin/bash
PS1='$ '
. ~/.bashrc
echo "TEST_TEXT = $TEST_TEXT"
read
and .bashrc will get source everytime you run it.
Now to using bash under Linux.
When you are running a bash session in a terminal you are inside of an interactive environment and you can edit .basrc and source it at any given time.
You source .bashrc like this:
source ~/.bashrc or . ~/.bashrc
Now, let's say you have a bash script that you want to run. You can run in in a terminal, but that is not the subject of this post. You can run it via a file manager, like Dolphin, thunar, ... or you can put a shortcut to it on your desktop.
If you want to source .bashrc in that script, it won't work, because running via file manager or desktop is running a bash script in an non-interactive environment. .bashrc notices that and does not do anything. In fact if you look at .bashrc you will find something like this:
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
at the beginning of you .bashrc.
But there is a solution for this. Put PS1='$ ' in your script before sourcing .bashrc.
Examples:
- run a terminal
- edit .bashrc and put
export TEST_TEXT='My test text' in your .bashrc
- make a new script test.sh:
#!/bin/bash
. ~/.bashrc
echo "TEST_TEXT = $TEST_TEXT"
read
- make it executable
chmod +x test.sh
- run it and you should get something like this:
TEST_TEXT =
- now source .bashrc and run the test.sh script
. ~/.bashrc
./test.sh
- and you get
TEST_TEXT = My test text
If you run this script via file manager you will always get TEST_TEXT =
Change the script to
#!/bin/bash
PS1='$ '
. ~/.bashrc
echo "TEST_TEXT = $TEST_TEXT"
read
and .bashrc will get source everytime you run it.
nedelja, 1. januar 2012
2012
Let 2012 be a special one.
My New Year's resolution was also to blog more ofter with some interesting dtuff about Linux, version control, Java, ....
My New Year's resolution was also to blog more ofter with some interesting dtuff about Linux, version control, Java, ....
četrtek, 27. oktober 2011
Xmarks
Usually I'm using two web broswers: Firefox and Chrome.
I always tried having one bookmarks set. I never found a way to share them between those web browsers. I've tried exporting bookmarks from one browser and importing into another, but that didn't feel right.
Luckly, yesterday I found Xmarks. Now my bookmarks are in the cloud :)) and I can share them easyly between Firefox and Chrome, since Xmarks has plugins for both.
torek, 14. junij 2011
KDE Konsole
I've been a happy KDE user since the eary days of it.
I've also used Konsole as my primary terminal application, but in recent Kubuntu releases it became slow.
Yesterday I switched to good old xterm with screen:
and in xterm I start screen with 10 sessions.
Now everything is fast again. :)
I've also used Konsole as my primary terminal application, but in recent Kubuntu releases it became slow.
Yesterday I switched to good old xterm with screen:
xterm -bg black -fg grey -fn -*-console-*-*-*-*-*-*-*-*-*-*-*-* -geometry 166x45
and in xterm I start screen with 10 sessions.
Now everything is fast again. :)
sobota, 16. april 2011
Is my application running?
A neat way to check if a instance of an application is already running is to use FileChannel and it's ability to lock it.
An example:
lock() will block, but you could use tryLock() to check it the fileChannel is already locked.
I've been using it in our application on Linux and Windows.
An example:
File lockFile = new File("APP_NAME.lock");
FileChannel fileChannel = new RandomAccessFile(lockFile, "rw").getChannel();
FileLock fileLock = fileChannel.lock();
lock() will block, but you could use tryLock() to check it the fileChannel is already locked.
I've been using it in our application on Linux and Windows.
ponedeljek, 14. februar 2011
Mercurial server installation for Windows
Installation of hgweb interface:
- install Apache HTTPD 2.2 to c:/Apps/Apache
- install Python 2.6 to c:/Python26
- install Mercurial to C:/Apps/HG
- install EasyInstall
This will find your Python installation and install it there.
- put c:/Python26 and c:/Python26/Scripts in you PATH
- install Flup Python module
easy_install flup-1.0.3.dev_20110111-py2.6.egg
- unzip C:/Apps/HG/library.zip C:/Apps/HG/dev
- copy c:/Apps/HG/templates directory to c:/Apps/HG/dev/templates
I have my Mercurial repositories in d:/HG/repos.
hgweb.fcgi in d:/HG looks like:
- configuration file for hgweb (d:/HG/hgweb.config) looks like:
- each repository under d:/HG/ has hgrc (in UTF-8) like this:
NOTE: debug and verbose have to be false
- edit c:/Apps/Apache/conf/httpd.conf and add:
- if you want to limit access to repositories add this to c:/Apps/Apache/conf/httpd.conf
- then add valid users to D:/HG/hgusers like this:
- install Apache HTTPD 2.2 to c:/Apps/Apache
- install Python 2.6 to c:/Python26
- install Mercurial to C:/Apps/HG
- install EasyInstall
This will find your Python installation and install it there.
- put c:/Python26 and c:/Python26/Scripts in you PATH
- install Flup Python module
easy_install flup-1.0.3.dev_20110111-py2.6.egg
- unzip C:/Apps/HG/library.zip C:/Apps/HG/dev
- copy c:/Apps/HG/templates directory to c:/Apps/HG/dev/templates
I have my Mercurial repositories in d:/HG/repos.
hgweb.fcgi in d:/HG looks like:
#!C:/Python26/python.exe -u
#
# An example FastCGI script for use with flup, edit as necessary
# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "d:/HG/hgweb.config"
# Uncomment and adjust if Mercurial is not installed system-wide:
import sys
sys.path.insert(0, "C:/Apps/HG/dev")
# Uncomment to send python tracebacks to the browser if an error occurs:
import cgitb; cgitb.enable()
import os
os.environ["HGENCODING"] = "UTF-8"
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb
from flup.server.fcgi import WSGIServer
application = hgweb(config)
WSGIServer(application).run()
- configuration file for hgweb (d:/HG/hgweb.config) looks like:
[paths]
# One repository
#FOO = d:/HG/repos/FOO
# All repositories in d:/HG/repos
/ = d:/HG/repos/**
[web]
style = gitweb
- each repository under d:/HG/ has hgrc (in UTF-8) like this:
[web]
description = Repository description
style = gitweb
allow_push = *
push_ssl = false
verbose = false
allowbz2 = yes
allowgz = yes
allowzip = yes
[ui]
username = Owner of repo <repo.owner@example.com>
debug = false
NOTE: debug and verbose have to be false
- edit c:/Apps/Apache/conf/httpd.conf and add:
LoadModule cgi_module modules/mod_cgi.so
LoadModule env_module modules/mod_env.so
SetEnv FCGI_FORCE_CGI Y
ScriptAliasMatch ^/hg(.*) d:/HG/hgweb.fcgi$1
<Directory d:/HG>
Options ExecCGI FollowSymLinks
AllowOverride None
AddHandler cgi-script .cgi
Allow from all
AllowOverride All
</Directory>
- if you want to limit access to repositories add this to c:/Apps/Apache/conf/httpd.conf
<Location /hg>
AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile D:/HG/hgusers
Require valid-user
</Location>
- then add valid users to D:/HG/hgusers like this:
htpasswd -c D:/HG/hgusers frodo # creates file D:/HG/hgusers and adds user frodo
htpasswd D:/HG/hgusers sam # only add usersam to exising D:/HG/hgusers file
DB2 SQL440 or SQL901 on DELETE
If you get SQL440 or SQL901 when you try to delete from a table, you might encountered this problem. The solution is to recreate all foreign keys that point to this table (MY_TABLE is the SQL script below).
The SQL to generate that SQL script for you is this (statement delimiter is #):
SELECT 'ALTER TABLE EMGSYS.' || TABNAME || ' DROP CONSTRAINT ' || CONSTNAME || '#' || CHR(13) || CHR(10) ||
'ALTER TABLE EMGSYS.' || TABNAME || ' ADD CONSTRAINT ' || CONSTNAME || ' FOREIGN KEY (' || TRIM(FK_COLNAMES) || ') REFERENCES EMGSYS.' || REFTABNAME || '(' || TRIM(PK_COL
NAMES) || ') ON DELETE ' ||
(CASE WHEN DELETERULE = 'R' THEN 'RESTRICT' WHEN DELETERULE = 'C' THEN 'CASCADE' END) || ' ON UPDATE ' || (CASE WHEN UPDATERULE = 'R' THEN 'RESTRICT' WHEN UPDATERULE = 'A
' THEN 'NO ACTION' END) || '#'
FROM SYSCAT.REFERENCES WHERE REFTABNAME = 'MY_TABLE' ORDER BY TABNAME WITH UR
There are still some constands missing in DELETERULE and UPDATERULE. The various values can be seen here.
The SQL to generate that SQL script for you is this (statement delimiter is #):
SELECT 'ALTER TABLE EMGSYS.' || TABNAME || ' DROP CONSTRAINT ' || CONSTNAME || '#' || CHR(13) || CHR(10) ||
'ALTER TABLE EMGSYS.' || TABNAME || ' ADD CONSTRAINT ' || CONSTNAME || ' FOREIGN KEY (' || TRIM(FK_COLNAMES) || ') REFERENCES EMGSYS.' || REFTABNAME || '(' || TRIM(PK_COL
NAMES) || ') ON DELETE ' ||
(CASE WHEN DELETERULE = 'R' THEN 'RESTRICT' WHEN DELETERULE = 'C' THEN 'CASCADE' END) || ' ON UPDATE ' || (CASE WHEN UPDATERULE = 'R' THEN 'RESTRICT' WHEN UPDATERULE = 'A
' THEN 'NO ACTION' END) || '#'
FROM SYSCAT.REFERENCES WHERE REFTABNAME = 'MY_TABLE' ORDER BY TABNAME WITH UR
There are still some constands missing in DELETERULE and UPDATERULE. The various values can be seen here.
ponedeljek, 7. februar 2011
Mercurial
At our company we used (well, still using) CVS as our versioning system. We've finally moved one of our main projects to Mercurial. I've been given a task to expose the repository over HTTP and securing access to it. In the following days I will post how I did that on Windows. Oh, well, I know. I'd rather use Linux, but what can you do....
sobota, 1. januar 2011
torek, 14. december 2010
Is this for real?
Read what Bjarne Stroustrup said about creating C++ here. Then tell me what you think.
I must admit I always found C++ a bit weird. :)
I must admit I always found C++ a bit weird. :)
petek, 15. oktober 2010
More space on Linux HOME partition
I've been trying to post this for a while, but never came to it.
Here it goes.
On every Linux partition there is a certain percent (usually 5%).
For certain partition you can check the amount of reserved space like this:
sudo dumpe2fs /dev/sda3 | grep "Reserved block count"
On my computer I had about 6Gb of reserved space.
You can gain those 6Gb of space back simply by using:
sudo tune2fs -m 0 /dev/sda3
I DON'T recomend using this on you root, boot, ... partitions. More on this can be read at How to Gain Couple Of Gb Of Free Space On Linux
Here it goes.
On every Linux partition there is a certain percent (usually 5%).
For certain partition you can check the amount of reserved space like this:
sudo dumpe2fs /dev/sda3 | grep "Reserved block count"
On my computer I had about 6Gb of reserved space.
You can gain those 6Gb of space back simply by using:
sudo tune2fs -m 0 /dev/sda3
I DON'T recomend using this on you root, boot, ... partitions. More on this can be read at How to Gain Couple Of Gb Of Free Space On Linux
četrtek, 23. september 2010
First
Two days ago I bought an HTC Desire phone with Android 2.2. I'm still learning, installing applications, ... This is my first smart phone and it's great. :))
This is also my first post from the phone.
petek, 7. maj 2010
Compile DB2 plugin for Qt on Linux
Steps:
- get Qt from Nokia's page
- install it
- run configure like this:
- this should compile DB2 plugin for Qt. Now you can use this installation or copy generated Qt db2 plugin (libsqldb2.so) to /usr/lib/qt4/plugins/sqldrivers
- get Qt from Nokia's page
- install it
- run configure like this:
./configure -plugin-sql-db2 -v -I /opt/ibm/db2/V9.7/include -L /opt/ibm/db2/V9.7/lib64/
make
make install (if you want to install it)
- this should compile DB2 plugin for Qt. Now you can use this installation or copy generated Qt db2 plugin (libsqldb2.so) to /usr/lib/qt4/plugins/sqldrivers
Access DB2 via ODBC on Linux
This is how to install ODBC on Linux (Kubuntu 10.04) and access it.
Steps:
- install DB2 (I always install everything)
- install unixODBC
- edit $HOME/.odbc.ini :
- run db2ca and add DB_NAME (don't forget to add ODBC)
- now you can use it on Qt for example like this:
Steps:
- install DB2 (I always install everything)
- install unixODBC
- edit $HOME/.odbc.ini :
[DB_NAME]
Description = Connection to DB_NAME
Driver=$HOME/sqllib/lib/libdb2.so
- run db2ca and add DB_NAME (don't forget to add ODBC)
- now you can use it on Qt for example like this:
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DB_NAME");
db.setUserName("DB_USER");
db.setPassword("DB_PASS");
db.open();
QSqlError error = db.lastError();
qDebug() << "db error = " << error;
QSqlQuery query = db.exec("SELECT 1 FROM SYSIBM.SYSDUMMY1");
while (query.next() == true) {
qDebug() << query.value(0).toString();
}
petek, 5. februar 2010
DB2 9.7.1, db2start and SQL1042C
As you may know I'm running Kubuntu 9.10.
The other day I installed DB2 Express-C 9.7.1 on it. When I tried db2start I got:
SQL1042C An unexpected system error occurred. SQLSTATE=58004
If you get the same try running db2ftok and then db2start again. It works for me.
The other day I installed DB2 Express-C 9.7.1 on it. When I tried db2start I got:
SQL1042C An unexpected system error occurred. SQLSTATE=58004
If you get the same try running db2ftok and then db2start again. It works for me.
ponedeljek, 1. februar 2010
"How to shoot yourself in the foot" in various languages
Follow this link.
ActiveX is the one I like the most. How about you ?
ActiveX is the one I like the most. How about you ?
petek, 29. januar 2010
petek, 1. januar 2010
Naročite se na:
Objave (Atom)