I did this ..

String filename = "tempoutfile.txt";
 String tablename = "table1";

	try{
			
	
		
			Connection con = DriverManager.getConnection("jdbc:mysql://localhost/Test","root","");
			Statement s=con.createStatement();
			ResultSet r=s.executeQuery("SELECT * INTO OUTFILE '"+ filename + "' FROM " + tablename);

			
			
			
		
			}catch(SQLException se){System.out.println(se.getMessage());}

But I can't find the file that is created!!

When I run the query in WAMP mysql console , it creates the out file in wamp\mysql\data . But not in previous case.

Where is this file created?

Add a System.out.println(System.getProperty("user.dir")) in there.

Otherwise use the search function for the OS.

But, the best way is to provide the full path to the file from the beginning. Why simply deal with defaults that can change due to configuration and/or operating parameters when you can control the operation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.