FielNotFoundException bei Datenbankverbindungsdatei

Lit-Web

Aktives Mitglied
Guten Morgen Leute. Mit den Pfadangaben in Java habe ich noch so meine Probleme.

Im Bildanhand seht ihr meine Dateistruktur und hier zeige ich den Code wo ich eine Instanz auf das Datenbankverbindungsobjekt bilde.

Hier der Code wo ich das einbinde.
Java:
import Connections.DbConnect;
import SystemGUI.MasterFrame;

public class Main {
	
	public static void main ( String [] args ) {
		DbConnect dbCon = new DbConnect( "../ConnectFiles/MySqlConnection.txt" );
		new MasterFrame( dbCon );
	}
}

Das Verbindungsobjekt wird dann im weiteren Programmverlauf an andere Mthoden und Klassen weiter gereicht.

Die gefeuerte Exception. ( ich denke das viele FEhler auf dem ersten aufbauen )
java.io.FileNotFoundException: ConnectFiles\MySqlConnection.txt (Das System kann den angegebenen Pfad nicht finden)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at Connections.DbConnect.inputDbConfFile(DbConnect.java:92)
at Connections.DbConnect.loadProperties(DbConnect.java:111)
at Connections.DbConnect.propertieDriver(DbConnect.java:125)
at Connections.DbConnect.connectToDb(DbConnect.java:63)
at CheckClasses.LoginCheck.<init>(LoginCheck.java:25)
at SystemGUI.LoginGui$ActionLoginBtn.actionPerformed(LoginGui.java:153)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Unknown Source)
at java.util.Properties.load0(Unknown Source)
at java.util.Properties.load(Unknown Source)
at Connections.DbConnect.loadProperties(DbConnect.java:111)
at Connections.DbConnect.propertieDriver(DbConnect.java:125)
at Connections.DbConnect.connectToDb(DbConnect.java:63)
at CheckClasses.LoginCheck.<init>(LoginCheck.java:25)
at SystemGUI.LoginGui$ActionLoginBtn.actionPerformed(LoginGui.java:153)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Wie muss ich nach meiner DAteistruktur den PFad zum Verbindungs File richtig angeben?

Danke für eure Hilfe Mfg Lit-Web
 
B

bERt0r

Gast
Schreib mal
Java:
File f=new File("../ConnectFiles/MySqlConnection.txt");
System.out.println(f.getAbsolutePath());
vorne in dein main
 

Der Müde Joe

Top Contributor
Kannst ja mal:
Java:
File file = new File("file");
System.out.println(file.getAbsolutePath());
machen. Dann weisst du wo du bist...bzw eben nicht.


EDIT:
2 ..... ein gedanke.... :D
 

Lit-Web

Aktives Mitglied
Da kommt dann als Ergebnis das raus.

D:\Softwareentwicklung\JavaProjekte\GregorWendtAdminPanel\ConnectFiles\MySqlConnection.txt
 

Oben