SQL and myBatis
I am equal with SQL
Monday, September 19th, 2016
Fourth week here we come. 8:00am started my Monday off looking up my future car. Dreams are something that disintegrate as people grow farther from childhood. Thoughts of becoming the best or accomplishing the impossible tend to become nothing more than fantasy. The radio this morning brought up a little blurb that said “what if the Earth is just a science project that aliens got a C+ on.” This stuck with me the whole drive, and I find myself loving this thought. My mind moved to imagination and all that space and time have to offer. That’s when the thought of dreams began something that upset me the more I thought about it. Anyway, if you want to know my future car will be a Suburu Legacy or a Mazda 6.
My last week of training began also. Instructor Calvin Vette (His Github) is our SQL teacher for the next four days. Intimidating man, but he seems very smart and knowledgeable. We went over some of the basics of SQL (such as Selects, Inserts, Deletes, Updates) and learned how to query his own personal database (His consulting business). This seems very useful, and will help to quicken the time it takes to load data. A great website for learning SQL is https://www.khanacademy.org/computing/computer-programming/sql.
Tuesday, September 20th, 2016
SQL is fantastic. We integrated more of traversing a database today, and learned how to import our database into Eclipse. Databases can be accessed and logged in through a database view, which can really help for when you need to access your data before you want to code it. With our best practices through my work, some querying takes too long and holds up the database for other developers. Having this tool allows us to see the data without virtually holding (or locking) it up.
J-Unit for anybody coding in Java is a must. Seriously, this little tool is a life saver. Today, Calvin took us through how to set up tests so that we could run a small piece of our code to see if it runs rather than having to redeploy our application every time. Don’t be like me and assume that typing more code is not worth it. In the long run J-Unit saved me hours, and I have only used it one day. You can go learn more about J-Unit by going to www.junit.org.
MyBatis could be Your Batis
Wednesday, September 21st, 2016
Wishing my nephew Bradley a happy 2nd birthday today. He is getting very big. What might be bigger than his size is myBatis (Github here). SQL is great and all, but it has no meaning if it cannot be nicely implemented with Java and/or Spring. My company decided to use myBatis instead of hibernate but it might be worth checking out both. This is a goal of mine in the near future, but myBatis is hopefully all I need to know. I am going to lay the ground work of how myBatis works.
First thing you want to do is make sure you have your maven dependency for myBatis, or the jar. Then you want to create a string to hold where you are going to put your SQL commands. For this I like to have a separate .XML file named something like “SQLMapConfig.xml”. This should be the full location, so package and all. Then create an inputStream to hold the information from the XML, and a SqlSessionFactory to hold this. Your XML should then look something like this:
Notice how this maps to another XML. This XML will then hold your database commands, and you should then be able to bring in information from your database. It is pretty awesome.
Thursday, September 22nd, 2016
Friday, September 23rd, 2016
Saturday, September 24th, 2016
I was suppose to go meet up with Dan (my consultant partner) to discuss some more about our potential business, but it ended up falling through. The downside to this was that I ended up just sleeping in. I spent my day going golfing with my brother and his friends, which was pretty fun. One of the best parts about a career in IT is you can kind of unwind on the weekends, but spend the money you make while doing it. I have a feeling money won’t be a problem, but I still do not have enough of it. After golf I went back to my girlfriends place. We are going to drink tonight and enjoy ourselves.
Sunday, September 25th, 2016
I am terribly ill. Alcohol mixed with extra alcohol was such a bad idea. It shall not happen again. Today was a waste day spent trying to cure myself of a hangover, and watching QVC. I had so much to get done today in reading, but it will have to wait. Drinking is the worst.