viernes, 27 de marzo de 2015

Creating a database connection to SAP ASE 16 from NetBeans

I would like to start saying this was a pain in the neck for sure, if I think this, the hardest part was the lack support from the SAP guys, specifically the official docs, independent blogs or user's list. So one client has a deployment  using SAP ASE, formerly called Sybase, it's a must to keep that DBMS -first weird decision- That's why I have to download latest ASE available to try connect it from NetBeans because the new project will use JSF -cool, but over ASE? even weird decision. So after many failed test here are the steps to connect to over Linux:

1. download ASE from SAP's website, the installation process is windows style: graphical, lack of details, slow, heavier, etc. Just try to take notes about the port connections. The server is started using a weird script, anyway, I installed it on /opt.

2. after start from command line, start glassfish and load Netbeans

3. from your project go to the services tab and create a new driver, then look for the jconn4.jar file, this is supplied from the ASE installation, you may download it from the official site as well.

4. find the main class using the button FIND, the class is the jdbc4 one.

5. then go to Database Option and choose "New Connection" option, load the driver you have created, click on next button.

6. in the next window type the USer Name and PAssword, you may use the 'sa' user in case you are not created another one, for this test is ok.

7. the most important part is this, the JBC Url, the sintaxis is this: jdbc:sybase:Tds::
now, from here I spend like 5 days figuring out why I could not connect to it, I was sure about the server's name and the port but I always got this error: UnknownHostException.  Here I discovered the lack of this DBMS, the official docs are usefulness, there is no end user support at blogs, social networks nor IRC, it was really cruel at this point.

8. so I decided to face this from another point of view, I used netstat to check if the port was available:
  netstat -atun

9. if you want to be more specific you may use:
 netstat -tulnp | grep 5000

So I found the port is listening but I figured out about the hostname (127.0.1.1) so I decided to include it in the JDBC url instead of server's name, so the url was: jdbc:sybase:Tds:127.0.1.1:5000

10. just press "Test Connection" button and... it works

and that's it, I can start to code my JSF CRUD's , in case you decide to work with ASE - for some weird decision- this will be really useful for you

Best!





sábado, 14 de febrero de 2015

export tables' structure using phppgadmin

this trick is useful - and easy- whether you need to export only your tables' structure from your PostgreSQL database you may follow these steps:

1. logon using phppgadmin

2. in left pane click on your database's name and expand it using the + icon, just like in the next image:




3. then, go to "tables" option and you will see all your tables; now, from the central toolbar click on the option "Export"



4.so in the next screen you got, just select the option "structure only", whether you would read the commands only at the bottom option menu click on "show", otherwise click on "Download". Finally click on "Export"



5. You will obtain a file with sql extension, whether you click on it, you will see all needed commands in other to export you tables' schema. it would be cool whether we decide the file's name (by default is named dump), in fact this would be nice in phpmyadmin too but for now we need to name it manually

Best

martes, 10 de febrero de 2015

fixing /var/lib/dpkg/lock problem in 12.04 LTS

Well it seems there is a problem with some spanish header in the ubuntu 12.04 LTS official repo, anyway, after did an apt-get update you may get this error:

E: No se pudo bloquear /var/lib/dpkg/lock – open (11: Recurso no disponible temporalmente)
E: No se pudo bloquear el directorio de administración (/var/lib/dpkg/), ¿quizás haya algún otro proceso utilizándolo?


in order to fix this issue, go to your terminal and use these commands:

sudo fuser -vki  /var/lib/dpkg/lock
sudo rm -f /var/lib/dpkg/lock
sudo dpkg –configure -a
sudo apt-get autoremove

that's it, now you may use apt-get install.

PS: I hate to be sick, this sore throat is worst I need it now, hope to be better in a few days

viernes, 6 de febrero de 2015

adding 'verbose' mode to dd command when cloning a drive

This is a really cool trick, I often use dd command to backup my important data collected from SD Card or USB stick, but sometimes is annoying when you only see a black screen hoping to finish it successfully, in fact dd command does not have a verbose mode, but you may fix this following these steps:

1. sudo apt-get install pv dialog

2. (pv -n /dev/sdb | dd of=myiso.iso bs=128M conv=notrunc,noerror) 2>&1 | dialog --gauge "Cloning USB to ISO file, please wait..." 10 70 0

that's all, try it and you'll see a progress bar, really cool

Best

jueves, 29 de enero de 2015

connect to an Access Point from command line

I am setting up a laptop with Debian with no-gui just for lab purposes that's why I need to connect it to the AP I have, from command line you may accomplish this task through these ones:

1.  sudo iwlist scan  //you will AP available, event the hidden ones

2. sudo iwconfig essid "AP name" // in my case:
   sudo iwconfig wlan0 essid "atenas"

3. sudo iwconfig wlan0 key s: 

4. get a IP from the dhcp:
  sudo dhclient wlan0

those steps worked for me, I read in several sites whether the AP has WPA2 passphare you should use the wpa_supplicant method, it may be true, but in my case it was not necessary, just check it in case some of the above steps do not work

Best

monitoring your physical resources on Ubuntu

Since I am working with a really heavy DBMS and IDE for a project, I start to ask me about my physical resources, RAM and Processor specifically, once I got a message from that DBMS that I had only 200 MB of RAM available and that was because that monster load a lot of subprocess -It's a Windows based DBMS, there are a lot of options better, but you know, the client always is right.

So, to monitor the resources you may use:

1. from command line: egrep --color 'Mem|Cache|Swap' /proc/meminfo

2. Use a really cool tool: gnome-system-monitor, you get a great graphs about used/free resources, really useful


jailing users with our FTP Server


I know FTP Server is still insecure for several reasons, I know there are better alternatives such as sftp, ssh or at least use ftp with SSL support, but we all know many users come from the dark side (win$$$... ) so maybe this post may be useful specially to them, in case you are running a FTP Server, it would be great restrict access just to the /home directory, in order to accomplish it these steps should be enough:

0. Create a directory for the "alienuser", it would be great in www directory in case you're at work and some consultant needs to upload something:
    sudo mkdir /var/www/alienuserdir

1. change owner group to that directory:
    sudo chown root.ftp /var/www/alienuserdir

2. addjust permission to the directory:
    sudo chmod 770 -R /var/www/alienuserdir

3. it would be great to do a ls -l to alienuserdir so you may check your changes
 
4. Create user's account from terminal:
   sudo adduser alienuser   //I like to user perl script adduser, save us a lot of time unlike useradd

5. Change the alienuser's home directory:
   sudo usermod --home /var/www/alienuserdir alienuser

6. Add alienuser to ftp group:
    sudo usermod -G ftp alienuser

7.  open the conf file of vsftpd:
     sudo nano /etc/vsftpd.conf

8. uncomment/add/change the next lines:
   anonymous_enable=NO
  local_enable=YES
  write_enable=YES
  chroot_local_user=YES
  local_root=/var/www/alienuserdir

9. save it and restart the service:
    sudo service vsftpd restart

10. that's all, now you may try using your favorite ftp client such as filezilla entering the host name, user(alienuser) and the password, it would be great whether you try to upload/download something as well

All the best