java - Unable to connect to SQL server on localhost -
i keep getting connection failed, dont know why, im running server on uniserverz , trying sql file localhost.
im using uniserverz (unicontroller.exe) , made .sqlite file using sqlite manager addon firefox. can me out here? thanks!
edit: ok, im trying load sqlite file c drive, have commented out command load localhost because doesnt work either. help?
package ui; import java.sql.*; import javax.swing.*; public class mysqlconnect { connection conn=null; public static connection connectdb(){ try{ class.forname("org.sqlite.jdbc"); connection conn = drivermanager.getconnection("jdbc:sqlite:c:\\uniserverz\\home\\database\\db"); // connection conn = drivermanager.getconnection("jdbc:mysql:\\localhost:3306\\database\\db\\student.sql","root","root"); joptionpane.showmessagedialog(null, "connection successful!"); return conn; } catch(exception e){ joptionpane.showmessagedialog(null, "connection failed"); return null; } } }
you work sqlite database used jar of mysql..
so correct line.
string driver = "com.mysql.jdbc.driver";
to
string driver = "org.sqlite.jdbc";
change url , add sqlite jdbc driver succesfull connection sqlite db.
and remove 1 /
below line after . jdbc:sqlite:
need /
.
connection conn = drivermanager.getconnection("jdbc:sqlite://localhost/database/db/database.sqlite");
thanks..
Comments
Post a Comment