I am trying to connect to a SQL server database from Netbeans 7.2.1, but get this error: [Microsoft][ODBC Driver Manager] Invalid string or buffer length
There seems to be something wrong with my connection, but I can’t find what. The data source is tested and works.
public static void main(String[] args) {
try{
Connection con = DriverManager.getConnection("jdbc:odbc:school");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select 'hello'");
while(rs.next()) {
System.out.println(rs.getString(0));
}
}catch(Exception e){
e.printStackTrace();
}
Does anyone know why? Grateful for help!
Maybe it would better to use native JDBC driver?
You can download it from: http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=21599
There is also some info that in Java8 ODBC bridge will be removed: https://bugs.java.com/bugdatabase/view_bug?bug_id=7176225