java - JdbcOdbc Error. i cant connect to the ODBC driver -
i'm studying program , i've tried solve myself, seems can't understand went wrong.
how can connect database? :)
here code below:
package payroll.system; import java.io.ioexception; import java.io.datainputstream; import java.io.fileinputstream; import java.sql.connection; import java.sql.drivermanager; import java.sql.sqlexception; import javax.swing.jdialog; import java.io.*; import java.util.*; import java.net.*; public class clsconnection { string url = ""; string username = ""; string password = ""; public connection setconnection(connection conn, string username, string password ) { try { properties props = new properties(); string filename = "makedb.ini"; fileinputstream in = new fileinputstream(filename); props.load(in); string drivers = props.getproperty("jdbc.drivers"); if(drivers != null) system.setproperty("jdbc.drivers", drivers); url = props.getproperty("jdbc.url"); username = props.getproperty("jdbc.username"); password = props.getproperty("jdbc.password"); conn = drivermanager.getconnection(url,username,password); }catch(sqlexception e) { system.err.println("sql exception"); e.printstacktrace(); } catch(ioexception e) { system.out.println("\nio exception"); } catch (exception e) { system.out.println("\nanother error"); } return conn; } }
this error after compile program:
sql exception java.sql.sqlexception: [microsoft][odbc driver manager] data source name not found , no default driver specified @ sun.jdbc.odbc.jdbcodbc.createsqlexception(jdbcodbc.java:6964) @ sun.jdbc.odbc.jdbcodbc.standarderror(jdbcodbc.java:7121) @ sun.jdbc.odbc.jdbcodbc.sqldriverconnect(jdbcodbc.java:3080) @ sun.jdbc.odbc.jdbcodbcconnection.initialize(jdbcodbcconnection.java:323) @ sun.jdbc.odbc.jdbcodbcdriver.connect(jdbcodbcdriver.java:174)
this due fact have not set odbc driver. set odbc driver need go administrative tools
under control panel
, chose appropriate driver setup odbc. can visit msdn more details. hope helps.
Comments
Post a Comment