Friday, October 30, 2009

Outer Join in MS Query

SELECT UffMacBen.`FIRST NAME`, UffMacBen.`LAST NAME`, UffMacBen.MAC_EMPLID, UffMacBen_Original.`FIRST NAME`, UffMacBen_Original.`LAST NAME`, UffMacBen_Original.MAC_EMPLID, UffMacBen.`FIRST NAME` FROM {oj `U:\uweb\members\2009\UFFmacBEN_09032009_copy`.UffMacBen UffMacBen LEFT OUTER JOIN `U:\uweb\members\2009\UFFmacBEN_09032009_copy`.UffMacBen_Original UffMacBen_Original ON UffMacBen.MAC_EMPLID = UffMacBen_Original.MAC_EMPLID} WHERE (UffMacBen_Original.MAC_EMPLID Is Null) UNION SELECT UffMacBen.`FIRST NAME`, UffMacBen.`LAST NAME`, UffMacBen.MAC_EMPLID, UffMacBen_Original.`FIRST NAME`, UffMacBen_Original.`LAST NAME`, UffMacBen_Original.MAC_EMPLID, UffMacBen.`FIRST NAME` FROM {oj `U:\uweb\members\2009\UFFmacBEN_09032009_copy`.UffMacBen_Original UffMacBen_Original LEFT OUTER JOIN `U:\uweb\members\2009\UFFmacBEN_09032009_copy`.UffMacBen UffMacBen ON UffMacBen_Original.MAC_EMPLID = UffMacBen.MAC_EMPLID} WHERE (UffMacBen.MAC_EMPLID Is Null)

Wednesday, October 14, 2009

Reading Excel Files from JDBC

Reading Excel Files from JDBC


I followed this example from JavaWorld and it worked. The instructions were good, except for the explanation of why qas was used as the name of the worksheet. The file was named qa.xls, the connection was qa-list; it took me a few minutes to realize that the name on the worksheet tab was qas.

Next step is to read my own file and do a query. It worked.

Next step is to perform an outer join between two sheets in the same file.

I have created the outer join with the following syntax (from ibm):

query = "SELECT * FROM {oj [09032009$] LEFT OUTER JOIN [09172009$] ON ([09032009$].MAC_EMPLID=[09172009$].MAC_EMPLID)}";

The names of my sheets in the file are 09032009 and 09172009.

I have determined the number of columns in the result set (from devdaily):

    //------------------------------------------------------//
   //  Here's the code to determine the number of columns  //
   //  in the ResultSet.                                   //
   //------------------------------------------------------//
   Statement st = conn.createStatement();
   ResultSet rs = st.executeQuery("SELECT * from Customer");
   ResultSetMetaData rsmd = rs.getMetaData();

   int numCols = rsmd.getColumnCount();
This can also be used to retrieve a column name.

Saturday, September 19, 2009

Replacing the Hard Drive on a Vista Machine

I dropped my HP tx2-1950dx Touchsmart laptop the other day. Since then, the hard drive has been making clicking sounds. After doing a disk check, it seems that the area from 11% to 14% on the hard disk is in bad shape.

I ordered a replacement disk from HP and it arrived the next day.

The first thing that needs to be done is to create a recovery disk that can be used to boot the system from the CD. In Vista, type Recovery in the start box and select Create Recovery Disks. This uses the recovery partition on the hard drive to create disks that will restore the system to its original factory state. Please note, this should have been done BEFORE the drive was damaged!!!

I have also created a current backup of the drive using the Windows Recovery option. I hope that I can use these disks to restore the disk instead of using the original state disks.

I also used DriveImageXML to create a compressed backup of the disk, but I will need to figure out a way to run the software before the main partition is installed.

I will follow the instructions on http://www.bleepingcomputer.com/tutorials/tutorial144.html
, once I have my recovery disks created.

After running the recovery disk, it seems that I will need to reinstall the factory state and then restore the later recovery that was created in Vista.

There is no way to load an image of the disk, except for the original factory state. The HP recovery disk does not allow access to the Repair Computer utility that is normally accessed after pressing F8 during boot. The only way to load another image is to buy a piece of hardware that will add the new drive to the computer through USB. I have ordered such a device.

I borrowed the hardware from a friend, but it didn't work on Vista. I bought the hardware for Vista. It still didn't work. Some of the partitions could be restored but not the boot partition. After several attempts, I surmised that the boot partition was corrupt, since I made it after the crash.

I ran the "restore to factory state" disks and reinstalled additional software and updates. All is well now.

Wednesday, August 26, 2009

Modifying the boot loader in Vista

I miss boot.ini. Why isn't there a GUI version of bcdedit?

I could run bcdedit, but I could not read the boot loader store without admin permission. I found a useful link that had the secret to running cmd with admin permission: type cmd in the search window in the start menu and hit CTRL-SHIFT-ENTER. So obvious.

bcdedit /? will show all the options.

bcdedit /v will show all the boot choices, including the annoying ID.

bcdedit /delete ID /cleanup will delete a choice from the list, as long as you get the ID correct.

If the partition has already been deleted, then this will not work!!!

bcdedit /deletevalue ID type will remove the entry, if you know the type.

bcdedit /? /TYPES will tell you more about the types.

bcdedit /deletevalue ID DESCRIPTION desc should remove the entry, but it doesn't, of course.

The problem that I have is that I have already deleted the Windows 7 partition, so none of the commands work. If I use the current OS, then they work. For instance,

bcdedit /set description "Vista Sucks"

works beautifully. I can even use the ID as

bcdedit /set ID description "Vista Really Sucks"

According to several posts, the /delete command should work but it doesn't.

The solution was to download easybcd

Wednesday, June 24, 2009

Fedora 11 Installing Samba

yum install samba
version 3.3.2-0.33.fc11

cd /etc/samba
mv smb.conf smb.conf.backup
vi smb.conf
[global]
workgroup = wrkgrp
netbios name = smbserver
security = SHARE
load printers = No
default service = global
path = /home
available = No
encrypt passwords = yes
[share]
writeable = yes
admin users = smbuser
path = /home/share
force user = root
valid users = smbuser
public = yes
available = yes

save and exit

add user smbuser to local and smb
useradd smbuser
passwd smbuser
smbpasswd -a smbuser

/etc/init.d/smb restart

new use z: \\ip\share passwd username

I could not connect from Windows.

I changed security to user: it still didn't work.

I am now reading an online Samba book.
http://us1.samba.org/samba/docs/man/Samba-HOWTO-Collection/


testparm is a command that will test the configuration of the samba conf file.
testparm /etc/samba/smb.conf

The file passes the test.

Optimize the file and strip all comments with
testparm -s source dest

SWAT is a web-based config tool. I will look into that after I get the conf file working.

Display all shares that are defined on a host:
smbclient -L hostname

This asks for a password for the current user. Even if I am logged in as the smb user, I am unable to connect.

Do an anonymous login by addeng -N to the command. I am able to see the share that I created.

Connect to home dir:
smbclient //host/user
This also requires password and fails.

/etc/sysconfig/network contains nameservers and hostname.
Where is the alias for eth0 and wlan0 defined? There is no /etc/modprobe.conf

Name resolution of DHCP addresses needs to be hardcoded, which defeats DHCP. I found a link,
http://www.cameratim.com/computing/linux/using-bind-as-a-local-dns-server, that indicates how to get around this. I will investigate later; for now I am hardcoding the DHCP address.

I failed to start nmb. Both the nmb and smb services must be running.
service smb start
service nmb start

Test if all the appropriate services are running (from http://troy.jdmz.net/samba/fw/):
# service smb stop
# netstat -ln > netstat-ln-smb.before
# service smb start
# netstat -ln > netstat-ln-smb.after
# diff netstat-ln-smb.*

Open firewall for udp and tcp in the /etc/sysconfig/iptables file:
-A INPUT -p udp -m udp --dport 137 -j ACCEPT
-A INPUT -p udp -m udp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT

Then restart the firewall
service iptables restart

The smbserver is now visible from the Window machine. I am still unable to connect to a share.

Tried a simple config from http://us6.samba.org/samba/docs/man/Samba-Guide/simple.html#draft-smbconf
[global]
workgroup = MIDEARTH
security = SHARE

[Plans]
path = /plans
read only = Yes
guest ok = Yes

When I tried smbclient -L server -Uroot%passwd, I got an error about LANMAN authorization. I fixed it by adding the following to the global section of the conf file and restarted smb:
client lanman auth = Yes
lanman auth = Yes

I can now see the server and the share (though I changed the name of the workgroup, but windows still sees the old one); however, when I try to access the share, my Linux security warns me that someone is trying to access my home directory. I placed the share in my home directory, so the error is correct. I will move the share. I just noticed that on Linux, the new workgroup name is not recognized, either.

I seem to being editing the wrong smb.conf file. The changes that I am making are not being implemented. I am editing /etc/samba/smb.conf ... No, I am editing the correct file, but the workgroup command in the global section is changing the domain, but not the workgroup.

I tried following the advice of the AVC warning: setsebool -P samba_enable_home_dirs=1, it did not resolve the problem.

I am still getting the home dir error; eventhough I moved the directory to the root. I will try moving it to /tmp ... Did not work.

I have added the following share
[homes]
browseable = ok
guest ok = yes


I can now access homes, but it opens my root directory.

I am able to mount a windows share with
mount.cifs //ip/path /mnt
It asks for a password.

I found a page on printing from linux to a windows printer: http://www.math.colostate.edu/~reinholz/freebsd/smb_print_client.html

In the original smb.conf, there are comments about SELinux for home directories and domains.
setsebool -P samba-domain-controller on
setsebool -P samba-enable-home-dirs on

There is also a comment about setting samba-share-t for new directories, for allowing SELinux to write to a dir.

Use the command ls -ldZ to see the context for a directory.

I used the original smb.conf file and I can access home directories.

Installing Fedora 11 on Eee PC

Fedora is using anaconda 11.5.0.59 as its installer.

Graphical screen with fedora logo: click Next.
Select Language: Next
Select Keyboard: Next
Finding storage devices ...
Name this computer - Hostname: eeepc: Next
Map of globe; select city in time zone: America/NY: next (check box for System clock uses UTC: checked)
root password: Next
Partition drives: sda and sdb; sda contains /boot: Next
Write changes to disk
Failed! Could not mount /boot

Restarted
...
Write changes to disk
Installation packages: Office and Productivity; Installation repo; Customize later:Next
Checking Dependencies
Starting Install
Installing 1091 packages

Congratulations. Reboot and install updates.

Additional configuration: Forward
License info: Forward
Create user (can set up network login here): Forward
Set date: Forward
SMOLT is hardware profiler; send profile: Finish

Thursday, May 28, 2009

JSP include tag versus include directive

The first thing to note is that if either of these directives fails, then the page stops loading.

The directive will accept a relative path from the current location; the tag must have a path that starts with /, which is the root of the web application, not the root of the server.

The difference between the two is how they handle dynamic content. The tag includes the output of the dynamic reference in the page at runtime; the directive includes the contents of the dynamic reference when the including JSP is compiled into a servlet.

I am hard pressed to devise an example using JSPS that has different output for the tag and the directive. The directive can only include actual files, so the directive is useless if CGI or PHP files are to be included.

If the tag includes a reference to a servlet, be sure that the servlet does not close the output stream. This is a problem for a servlet that forwards to a JSP, since the output stream is closed after the forward is complete.

Both by-pass the security constraints in the web.xml file. Both can access WEB-INF, directly.

Both can only include resources that are in the web application.



I just read on another site that the difference is when they are loaded.

The tag loads at runtime.

<jsp:include page="includedPage" /> 

The directive loads at compile time.

<%@ include file="banner.jsp" %> 

From http://stackoverflow.com/questions/9188478/how-to-implement-a-include-jsp-tag

More Blogs

Followers