• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

setting the driver to access database??

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
i have the folowing prog. to acces database.
it compiles and runs good ,but i got no result.
i know i have to go to setting and to control panel to set up something relkated to the driver,i do not remember how to do it.
please let me know how to do it.
thanks alot for your time.
import java.util.*;
import java.net.*;
import java.sql.*;
import java.io.*;
import java.util.*;
public class DatabaseAccess
{
public static void main(String arg[])
{


try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

String url = "jdbc dbc:moh";
Connection connection =
DriverManager.getConnection(
url,"","");





Statement stmt = connection.createStatement();

// Get data using colunm names.
ResultSet rs = stmt.executeQuery(
"SELECT * FROM mine");

while (rs.next())
{


String s = rs.getString("First Name");
System.out.println(s);
}

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

}
catch (ClassNotFoundException e)
{
System.out.println(e.getMessage());
}


}

}

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tom,

i know i have to go to setting and to control panel to set up something related to the driver,i do not remember how to do it.


You remember correctly. You will have to go the control panel -> 32 bit ODBC drivers and then create a System DSN called moh this will register the ODBC data source and your program then should give the expected output.
HTH,
Shubhangi
 
We can fix it! We just need some baling wire, some WD-40, a bit of duct tape and this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic