Jim McKinley

Greenhorn
+ Follow
since Jul 14, 2015
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jim McKinley

I have yet to try to connect to a database without the JDBC - ODBC bridge.

Can someone provide a simple example connecting to Microsoft SQL Server using JDBC? Also, how do you do a query? Possibly just to loop through a simple set of data and then; finally, closing the database. IF I could see a simple/complete example, I think it would help immensely or at least provide enough information that I can ask more meaningful questions.

If possible, can someone show doing a similar example in MySQL?

I've been trying to find some examples but either the examples leave out important steps OR the examples I've found use the JDBC - ODBC bridge.

Thanks in advance!!
Never mind... I just figured it out. I was in the package directory. I changed to where I was one level above that directory and tried "java myPackage.Test" again and it worked.
7 years ago
I have run java apps; however, until now, I've never run the command line version. I created a simple app called "Test.java". The code will compile just fine (using javac); however, I can't get it to run (UNLESS I remove the package from the source code and recompile). Here is the simple code:



This version of the code was placed in a path like: G:\JavaExamples\myPackage\Test.java... again, it compiles just fine; however, I get the error "could not find or load main class...."

I tried using the command line in two ways (in both cases, I started the run by going to the folder in the command prompt):

1. java myPackage.Test
2. java Test

If I comment out the package in the source:



And recompile, I can successfully run the code using: java Test

What am I doing wrong?

Thanks!!

Note: For some reason, my indentations in my code are not showing up in this post; however, when I came back to edit this post, I see them
7 years ago