Reputation: 1715
I want to access Local MySQL files in a similar way it can be accessed using SmallSQL. Eg.
String driver = "smallsql.server.SSDriver";
String url = "jdbc:smallsql:C:\\Users\\user\\Desktop\\SQuirreL\\db";
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url);
System.out.println("Connected to smallSQL database");
As you can see, i can move my db folder anywhere on my local machine and all i have to do is to mention the path of db folder to connect with it. Similar implementation in mysql, looks like:
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection(jdbc:mysql://localhost:3306/db?characterEncoding=UTF8&user=root&password=#$%^";);
System.out.println("Connected to MySQL database");
}
So I want to know is there a similar way to do something with MySQL databases, as we can do with SmallSQL, which are stored in $path_to_myql/mysql/data/db ?
Thanks
Upvotes: 2
Views: 374
Reputation: 116207
According to documentation, local socket connection is only available on Unix systems (not on Windows).
More importantly, though, you have to realize that SmallSQL is very similar to SQLite because its whole database engine is simply a library linked by your process, and that's why you can open and access database directly on disk.
MySQL, on other hand, runs fully dedicated server daemon, which serves multiple clients and has full control over its internal database files. It can be running on the same physical machine or on remote host, and you cannot tell it where your data files are.
Long story short - you should live with it. MySQL is more complicated, but also works much faster than SmallSQL or SQLite.
Upvotes: 1