\documentclass[10pt]{article}
\usepackage{listings}
\usepackage{color} 
%
\definecolor{hellgelb}{rgb}{1,1,0.8}
\definecolor{colKeys}{rgb}{0,0,1}
\definecolor{colIdentifier}{rgb}{0,0,0}
\definecolor{colComments}{rgb}{1,0,0}
\definecolor{colString}{rgb}{0,0.5,0}

\lstset{%
   morekeywords={AND,ASC,avg,CHECK,COMMIT,count,DECODE,DESC,DISTINCT,%
                 GROUP,IN,LIKE,NUMBER,ROLLBACK,SUBSTR,sum,VARCHAR2}%
}
\lstset{%
    float=hbp,%
    basicstyle=\ttfamily\small, %
    identifierstyle=\color{colIdentifier}, %
    keywordstyle=\color{colKeys}, %
    stringstyle=\color{colString}, %
    commentstyle=\color{colComments}, %
    columns=flexible, %
    tabsize=2, %
    frame=single, %
    extendedchars=true, %
    showspaces=false, %
    showstringspaces=false, %
    numbers=left, %
    numberstyle=\tiny, %
    breaklines=true, %
    backgroundcolor=\color{hellgelb}, %
    breakautoindent=true, %
    captionpos=b%
}
\usepackage{ifpdf}
\ifpdf
    \usepackage[colorlinks,linktocpage]{hyperref}
\fi
\begin{document}
\title{Colored Listings}
\author{Herbert Voss}
\date{12.July 2003}
\maketitle

\tableofcontents

\section{The Preamble Definitions}
\begin{lstlisting}[language={[LaTeX]TeX}]
\definecolor{hellgelb}{rgb}{1,1,0.8}
\definecolor{colKeys}{rgb}{0,0,1}
\definecolor{colIdentifier}{rgb}{0,0,0}
\definecolor{colComments}{rgb}{1,0,0}
\definecolor{colString}{rgb}{0,0.5,0}

\lstset{%
  language={SQL},%
   morekeywords={AND,ASC,avg,CHECK,COMMIT,count,DECODE,DESC,DISTINCT,%
                 GROUP,IN,LIKE,NUMBER,ROLLBACK,SUBSTR,sum,VARCHAR2}%
}
\lstset{%
    float=hbp,%
    basicstyle=\ttfamily\small, %
    identifierstyle=\color{colIdentifier}, %
    keywordstyle=\color{colKeys}, %
    stringstyle=\color{colString}, %
    commentstyle=\color{colComments}, %
    columns=flexible, %
    tabsize=4, %
    frame=single, %
    extendedchars=true, %
    showspaces=false, %
    showstringspaces=false, %
    numbers=left, %
    numberstyle=\tiny, %
    breaklines=true, %
    backgroundcolor=\color{hellgelb}, %
    breakautoindent=true, %
    captionpos=b%
}
\end{lstlisting} 

\section{First Example}
\begin{verbatim}
\begin{lstlisting}[language=SQL,label=sql:label1,caption=caption1]
GROUP = FROM ...
\end{lstlisting}
\end{verbatim}

\begin{lstlisting}[language=SQL,label=sql:label1,caption=caption1]
GROUP = FROM ...
\end{lstlisting}

\section{Second Example}
\begin{verbatim}
\begin{lstlisting}[language=Java,%
     alsolanguage=SQL,%
     label=sql:label2,caption=caption2]
GROUP = FROM ...
		public static void main() {
			(...)
		}
\end{lstlisting}
\end{verbatim}


\begin{lstlisting}[language=Java,%
    alsolanguage=SQL,%
    label=sql:label2,caption=caption2]
GROUP = FROM ...
		public static void main() {
			(...)
		}
\end{lstlisting}

\section{XML Example}
\begin{verbatim}
\begin{lstlisting}[language=XML,caption={example document structure},label={ex-doc}]
<!-- SQL Anweisungen -->
[ ... ]
\end{lstlisting}
\end{verbatim}

\begin{lstlisting}[language=XML,caption={example document structure},label={ex-doc}]
<!-- SQL Anweisungen -->
<!-dburl="jdbc:odbc:adr"->
<!-dbuser="gast"->
<!-dbpasswd="gast"->
<dbstmt>
 select
	id_, name_, vorname_, str_, ort_
 from
	adr
 order by 2, 3
</dbstmt>
<!-- Ende SQL Anweisungen -->
<?xml version="1.0"?>
<!DOCTYPE adressen SYSTEM "adressen.dtd">
<adressen>
<!-- Ausgabe -->
<dbdata>
  <adresse id="##1##" >
    <name><family>##2##</family> <given>##3##</given></name>
    <strasse>##4##</strasse>
    <ort>##5##</ort>
  </adresse>
</dbdata>
<!-- Ende Ausgabe -->
</adressen>
\end{lstlisting}



\end{document}
