Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Ronald Powane
Java
1 Answer(s)      3 years and 11 months ago
Posted in : Java Beginners


I have written the code to query the database to retrieve the flight details and the schedule of the flights, however, when executing the code i experience an error which says Error :java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified. can you please identify and state the reason behind this error. In addition, provide the correct solution for the same. The code is as follows:

import java.sql.*; public class Test { public static void main(String args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:air_dsn", "sa", "pass@123"); Statement stat = con.createStatement(); ResultSet rs = stat.executeQuery("select flno,flroute, dp_timings from schedule"); System.out.println("* Flight Schedule ***"); while (rs.next()) System.out.print(rs.getString(1) + " : " + rs.getString(2)+ " : "+rs.getString(3) + "\n"); con.close(); con = DriverManager.getConnection("jdbc:odbc:air_dsn","sa", "pass@123"); rs = stat.executeQuery("select flno,aircrafttype,seating_capacity from Flights"); System.out.println("* Flight Details ***"); while (rs.next()) System.out.print(rs.getString(1) + " : " + rs.getString(2)+ " : "+rs.getInt(3) + "\n"); con.close(); } catch (Exception e) { System.out.println("Error :"+e); } } }


Advertisement
View Answers

February 9, 2011 at 10:37 AM


Set up DSN connection

Follow these steps:

1)Go to the start<<Control Panel<<Administrative Tools<< data sources.

2)Click Add button and select the driver Microsoft Access Driver(*.mdb).

3)After selecting the driver, click finish button.

4)Then give Data Source Name and click ok button.

5)Your DSN will get created.

6) Restart your command prompt and compile your java code.



Related Tutorials/Questions & Answers:
java
java  diff bt core java and java
java
java  what is java
Advertisements
Java
Java   Whether Java is pure object oriented Language
java
java  different between java & core java
java
java  explain technologies are used in java now days and structure java
java
java   why iterator in java if we for loop
JAVA
JAVA  how the name came for java language as "JAVA
java
java  what is java reflection
java
java  is java open source
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
java
java  write a java program using filenotfoundexception
java
java   difference between class and interface
java
java  why multiple inheritance is not possible in java
java
java  is java purely object oriented language
java
java  how use java method
java
java  send me java interview questions
java
java  write a program in java to acess the email
java
java  Write a java code to print "ABABBABCABABBA
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  give a simple example for inheritance in java
Java
Java  how to do java in command prompt
java
java  sample code for RARP using java
java
java  RARP implementation using java socket
Java
Java  how to draw class diagrams in java
java
java  explain object oriented concept in java
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  what are JAVA applications development tools
java
java  why to set classpath in java
Advertisements
 

 

 

DMCA.com