mgrex's Profile User Rating: -----

Reputation: 3 Apprentice
Group:
Active Members
Active Posts:
219 (0.11 per day)
Joined:
25-March 10
Profile Views:
2,075
Last Active:
User is offline Aug 29 2015 03:34 PM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0
Icon   mgrex has not set their status

Posts I've Made

  1. In Topic: Modify xml file to accept Class and MySQL table with different names?

    Posted 10 Aug 2015

    I've gone ahead and added, @Table(name = "Employee"), to the Ch_09_03_Employee class:

    Spoiler


    The XML file looks like this:
    Spoiler


    The following output results:
    Spoiler


    Line 18 states:
    Caused by: org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 56; Attribute "table" must be declared for element type "mapping".
  2. In Topic: Display MySQL Workbench contents in Java Eclipse?

    Posted 5 Aug 2015

    View Postg00se, on 05 August 2015 - 01:22 PM, said:

    Your sql string has incorrect spacing after concatenation


    That fixed it.

    Using employee in place of e, and department in place d resulted in:

    Loading JDBC driver...
    JDBC driver successfully loaded!
    Connecting to the MySQL database...
    MySQL Database connected!
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'employee.name' in 'field list'
    Closing the connection.
    
    


    The following resulted in the author's output. Thank you for your help.

    String query = " select e.name, d.DName " + " from employee E, department D " +						
    				" where e.DNR = d.DNR; ";
    


    It seems 'e' and 'd' were defined in " from employee E, department D " "
  3. In Topic: Display MySQL Workbench contents in Java Eclipse?

    Posted 5 Aug 2015

    View Postg00se, on 05 August 2015 - 12:22 PM, said:

    You need to make sure that jar is added to your project


    I updated my previous post.

    I went ahead and restarted eclipse, and I did not have to re-add the JAR file.

    The following queries were able to be executed successfully in Workbench:

    select name from employee;
    select DNR from employee;
    select DName from department;
    select DNR from department;
    
    


    In line 20 of the full source code, I changed the statements to:
    String query = "select employee.name, department.DName" + "from employee E, department D" +						
    				"where employee.DNR=department.DNR;";
    
    


    There was no success.

    Spoiler
  4. In Topic: Display MySQL Workbench contents in Java Eclipse?

    Posted 5 Aug 2015

    Thank you for responding. Turns out the reason nothing was displayed was because of Eclipse in general. Not even a simple "Hello world" could display. So I had to restart it by forcibly shutting it down in Task manager. In Workbench the username is root without any password set (null).

    I got the following output, even after changing line 39 to, ' e.printStackTrace(); ':

    Spoiler


    Looks like, it can't find the com.mysql.jdbc.Driver. I'll try loading the jar file again.

    Loading the jar file again helped.

    I went ahead and used e.printStackTrace();, and got the following output:
    Spoiler


    I went ahead and used the original, System.out.println(e.toString());, and got:
    Spoiler
  5. In Topic: Syntax from textbook won't execute in query.

    Posted 2 Aug 2015

    The following seemed to have worked; by removing all quotation marks.

    CREATE TABLE employeeschema_01.Department (
    	DNR INT NOT NULL,
    	DName VARCHAR(45) NULL,
    	DAddress VARCHAR(45) NULL,
    	PRIMARY KEY (DNR))
    ENGINE = InnoDB;
    
    CREATE TABLE employeeschema_01.Employee 
    (
    	EmployeeID INT NOT NULL,
    	Name VARCHAR(45) NULL,
    	Gender VARCHAR(45) NULL,
    	DNR INT NULL,
    	PRIMARY KEY (EmployeeID),
    	INDEX DNRForeign_idx (DNR ASC),
    	CONSTRAINT DNRForeign FOREIGN KEY (DNR)				# Department table must be created first.
    		REFERENCES employeeschema_01.Department (DNR)
    	ON DELETE NO ACTION
    	ON UPDATE NO ACTION
        )    
        
    ENGINE = InnoDB;
        
    

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

mgrex hasn't added any friends yet.

Comments

mgrex has no profile comments yet. Why not say hello?